]> arthur.barton.de Git - bup.git/commitdiff
cmd/init: don't spit out a traceback on init error
authorGabriel Filion <lelutin@gmail.com>
Mon, 17 Jan 2011 02:19:25 +0000 (21:19 -0500)
committerAvery Pennarun <apenwarr@gmail.com>
Tue, 18 Jan 2011 20:33:21 +0000 (12:33 -0800)
When an error occurs during repository creation, 'bup init' currently
lets GitError exceptions leak out, printing a backtrace to unsuspecting
users in the process.

Intercept GitError exceptions that come out of git.init_repo() and print
out the message that it contains in a more friendly manner.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
cmd/init-cmd.py

index 04f32484d6bd78a6ad2c37022e5ac8af6cedd6a8..80037e94e37645b836f7fddd1b6ea7eff62fee5c 100755 (executable)
@@ -1,7 +1,10 @@
 #!/usr/bin/env python
+import sys
+
 from bup import git, options, client
 from bup.helpers import *
 
+
 optspec = """
 [BUP_DIR=...] bup init [-r host:path]
 --
@@ -14,10 +17,13 @@ if extra:
     o.fatal("no arguments expected")
 
 
-if opt.remote:
+try:
     git.init_repo()  # local repo
+except git.GitError, e:
+    log("bup: error: could not init repository: %s" % e)
+    sys.exit(1)
+
+if opt.remote:
     git.check_repo_or_die()
     cli = client.Client(opt.remote, create=True)
     cli.close()
-else:
-    git.init_repo()