]> arthur.barton.de Git - bup.git/blobdiff - lib/cmd/get-cmd.py
get: remove pointless git.repo() call
[bup.git] / lib / cmd / get-cmd.py
index 95d8f57fabf0328d28996478fe65dedfaa14995e..7fc741e04db4fa6f6f61eaabbdd2aa987d2c992a 100755 (executable)
@@ -1,7 +1,16 @@
 #!/bin/sh
 """": # -*-python-*-
-bup_python="$(dirname "$0")/bup-python" || exit $?
-exec "$bup_python" "$0" ${1+"$@"}
+# https://sourceware.org/bugzilla/show_bug.cgi?id=26034
+export "BUP_ARGV_0"="$0"
+arg_i=1
+for arg in "$@"; do
+    export "BUP_ARGV_${arg_i}"="$arg"
+    shift
+    arg_i=$((arg_i + 1))
+done
+# Here to end of preamble replaced during install
+bup_python="$(dirname "$0")/../../config/bin/python" || exit $?
+exec "$bup_python" "$0"
 """
 # end of bup preamble
 
@@ -12,7 +21,9 @@ from collections import namedtuple
 from functools import partial
 from stat import S_ISDIR
 
-from bup import git, client, helpers, vfs
+sys.path[:0] = [os.path.dirname(os.path.realpath(__file__)) + '/..']
+
+from bup import compat, git, client, helpers, vfs
 from bup.compat import argv_bytes, environ, hexstr, items, wrap_main
 from bup.git import get_cat_data, parse_commit, walk_object
 from bup.helpers import add_error, debug1, handle_ctrl_c, log, saved_errors
@@ -389,7 +400,7 @@ def handle_append(item, src_repo, writer, opt):
     if item.src.type == 'tree':
         get_random_item(item.spec.src, src_oidx, src_repo, writer, opt)
         parent = item.dest.hash
-        msg = b'bup save\n\nGenerated by command:\n%r\n' % sys.argv
+        msg = b'bup save\n\nGenerated by command:\n%r\n' % compat.argvb
         userline = b'%s <%s@%s>' % (userfullname(), username(), hostname())
         now = time.time()
         commit = writer.new_commit(item.src.hash, parent,
@@ -572,11 +583,10 @@ def log_item(name, type, opt, tree=None, commit=None, tag=None):
 def main():
     handle_ctrl_c()
     is_reverse = environ.get(b'BUP_SERVER_REVERSE')
-    opt = parse_args(sys.argv)
+    opt = parse_args(compat.argv)
     git.check_repo_or_die()
     if opt.source:
         opt.source = argv_bytes(opt.source)
-    src_dir = opt.source or git.repo()
     if opt.bwlimit:
         client.bwlimit = parse_num(opt.bwlimit)
     if is_reverse and opt.remote:
@@ -589,7 +599,7 @@ def main():
         dest_repo = LocalRepo()
 
     with dest_repo as dest_repo:
-        with LocalRepo(repo_dir=src_dir) as src_repo:
+        with LocalRepo(repo_dir=opt.source) as src_repo:
             with dest_repo.new_packwriter(compression_level=opt.compress) as writer:
                 # Resolve and validate all sources and destinations,
                 # implicit or explicit, and do it up-front, so we can