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>
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,