From 621fbd9f86da68e7bc6974fe59cf9e32c29cdd3c Mon Sep 17 00:00:00 2001 From: Zoran Zaric Date: Mon, 12 Aug 2013 16:20:12 +0200 Subject: [PATCH] git.py: don't automatically initialize ~/.bup if it doesn't exist. bup had a convenience feature where commands would automagically initialize a repo in ~/.bup if it didn't exist and no other BUP_DIR was given. This had the odd effect that when one forgot to specify BUP_DIR, a bup repo would be initialized in ~/.bup even though only a browsing command was used. This patch drops that behaviour. Now all repositories must be explicitly intiialized via "bup init". Signed-off-by: Zoran Zaric [rlb@defaultvalue.org: edit commit message; fix test ("set +e" during init run).] Signed-off-by: Rob Browning --- Makefile | 1 + lib/bup/git.py | 9 +++------ t/test-command-without-init-fails.sh | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+), 6 deletions(-) create mode 100755 t/test-command-without-init-fails.sh diff --git a/Makefile b/Makefile index 216bf98..97e2b72 100644 --- a/Makefile +++ b/Makefile @@ -90,6 +90,7 @@ runtests-cmdline: all t/test-meta.sh t/test-restore-single-file.sh t/test-rm-between-index-and-save.sh + t/test-command-without-init-fails.sh t/test.sh stupid: diff --git a/lib/bup/git.py b/lib/bup/git.py index 00975a7..5debc9a 100644 --- a/lib/bup/git.py +++ b/lib/bup/git.py @@ -849,12 +849,9 @@ def check_repo_or_die(path=None): os.stat(repo('objects/pack/.')) except OSError, e: if e.errno == errno.ENOENT: - if repodir != home_repodir: - log('error: %r is not a bup repository; run "bup init"\n' - % repo()) - sys.exit(15) - else: - init_repo() + log('error: %r is not a bup repository; run "bup init"\n' + % repo()) + sys.exit(15) else: log('error: %s\n' % e) sys.exit(14) diff --git a/t/test-command-without-init-fails.sh b/t/test-command-without-init-fails.sh new file mode 100755 index 0000000..896fc1f --- /dev/null +++ b/t/test-command-without-init-fails.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +. ./wvtest-bup.sh + +set -e -o pipefail + +WVSTART 'all' + +top="$(pwd)" +tmpdir="$(wvmktempdir)" +export BUP_DIR="$tmpdir/bup" + +bup() { "$top/bup" "$@"; } + +mkdir "$tmpdir/foo" + +set +e +bup index "$tmpdir/foo" &> /dev/null +index_rc=$? +set -e +WVPASSEQ "$index_rc" "15" + +rm -rf "$tmpdir" -- 2.39.5