]> arthur.barton.de Git - bup.git/commitdiff
git.py: don't automatically initialize ~/.bup if it doesn't exist.
authorZoran Zaric <zz@zoranzaric.de>
Mon, 12 Aug 2013 14:20:12 +0000 (16:20 +0200)
committerRob Browning <rlb@defaultvalue.org>
Sat, 17 Aug 2013 20:37:34 +0000 (15:37 -0500)
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 <zz@zoranzaric.de>
[rlb@defaultvalue.org: edit commit message; fix test ("set +e" during
 init run).]
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Makefile
lib/bup/git.py
t/test-command-without-init-fails.sh [new file with mode: 0755]

index 216bf983311fc883eb43d14f7ef22d0012c4087f..97e2b722fa09bb32eca7988a93bca3227256c294 100644 (file)
--- 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:
index 00975a713d8849f9d110d0271b657c535cd3b3d0..5debc9a5c6968933d341f93a9fba59778fb53e35 100644 (file)
@@ -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 (executable)
index 0000000..896fc1f
--- /dev/null
@@ -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"