]> git.michaelhowe.org Git - packages/b/bup.git/commitdiff
git.py: error when repo's parent dir absent
authorGabriel Filion <lelutin@gmail.com>
Mon, 17 Jan 2011 02:19:24 +0000 (21:19 -0500)
committerAvery Pennarun <apenwarr@gmail.com>
Tue, 18 Jan 2011 20:33:21 +0000 (12:33 -0800)
Currently, when you try to initialize a bup repository inside an
unexistant directory (e.g. BUP_DIR=some_dir/bup_repo, and some_dir does
not exist), bup has to call "git init" to then obtain an error code
which is not very significant to users.

Add a check for the existence of the repository's parent directory and
throw an exception with a more meaningful error message when that
happens.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
lib/bup/git.py

index 064bcdfd90218a9d73584a02654fff3813fb5829..b1350532ee870516803f3dbe7a07e2fcc61c07f4 100644 (file)
@@ -862,7 +862,10 @@ def guess_repo(path=None):
 def init_repo(path=None):
     """Create the Git bare repository for bup in a given path."""
     guess_repo(path)
-    d = repo()
+    d = repo()  # appends a / to the path
+    parent = os.path.dirname(os.path.dirname(d))
+    if parent and not os.path.exists(parent):
+        raise GitError('parent directory "%s" does not exist\n' % parent)
     if os.path.exists(d) and not os.path.isdir(os.path.join(d, '.')):
         raise GitError('"%d" exists but is not a directory\n' % d)
     p = subprocess.Popen(['git', '--bare', 'init'], stdout=sys.stderr,