From: Gabriel Filion Date: Mon, 17 Jan 2011 02:19:24 +0000 (-0500) Subject: git.py: error when repo's parent dir absent X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=05520573d14d587d92e2d857547608effafae6c3;p=packages%2Fb%2Fbup.git git.py: error when repo's parent dir absent 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 --- diff --git a/lib/bup/git.py b/lib/bup/git.py index 064bcdf..b135053 100644 --- a/lib/bup/git.py +++ b/lib/bup/git.py @@ -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,