]> arthur.barton.de Git - bup.git/commitdiff
midx: make passing idx files along with --dir work
authorJohannes Berg <johannes@sipsolutions.net>
Wed, 30 Dec 2020 22:10:19 +0000 (23:10 +0100)
committerRob Browning <rlb@defaultvalue.org>
Sun, 30 May 2021 16:24:40 +0000 (11:24 -0500)
If you do something like

bup midx --dir /some/dir/ ...

with some idx files ("..."), then things don't actually work
properly because --dir gets ignored in this case. Fix that.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/cmd/midx.py

index 3e764e6a9082793b5f5ec56f2fc1992702c054e6..e80afa1a171388f04bae8a02f8db0b4939503c8f 100755 (executable)
@@ -247,7 +247,6 @@ def do_midx_group(outdir, outfilename, infiles, auto=False, force=False,
 def main(argv):
     o = options.Options(optspec)
     opt, flags, extra = o.parse_bytes(argv[1:])
-    opt.dir = argv_bytes(opt.dir) if opt.dir else None
     opt.output = argv_bytes(opt.output) if opt.output else None
 
     if extra and (opt.auto or opt.force):
@@ -261,6 +260,8 @@ def main(argv):
         opt.max_files = max_files()
     assert(opt.max_files >= 5)
 
+    path = opt.dir and argv_bytes(opt.dir) or git.repo(b'objects/pack')
+
     extra = [argv_bytes(x) for x in extra]
 
     if opt.check:
@@ -268,7 +269,6 @@ def main(argv):
         if extra:
             midxes = extra
         else:
-            path = opt.dir or git.repo(b'objects/pack')
             debug1('midx: scanning %s\n' % path)
             midxes = glob.glob(os.path.join(path, b'*.midx'))
         for name in midxes:
@@ -278,12 +278,11 @@ def main(argv):
     else:
         if extra:
             sys.stdout.flush()
-            do_midx(git.repo(b'objects/pack'), opt.output, extra, b'',
+            do_midx(path, opt.output, extra, b'',
                     byte_stream(sys.stdout), auto=opt.auto, force=opt.force,
                     print_names=opt.print)
         elif opt.auto or opt.force:
             sys.stdout.flush()
-            path = opt.dir or git.repo(b'objects/pack')
             debug1('midx: scanning %s\n' % path_msg(path))
             do_midx_dir(path, opt.output, byte_stream(sys.stdout),
                         auto=opt.auto, force=opt.force,