From: Avery Pennarun Date: Sun, 13 Feb 2011 06:53:50 +0000 (-0800) Subject: cmd/join: add a new -o (output filename) option. X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=cf86321f17487240e1ffaf3a54b7302ba277b1ec;p=packages%2Fb%2Fbup.git cmd/join: add a new -o (output filename) option. This is a helpful way to have it open and write to the given output file. Signed-off-by: Avery Pennarun --- diff --git a/cmd/join-cmd.py b/cmd/join-cmd.py index edc5fcb..042b402 100755 --- a/cmd/join-cmd.py +++ b/cmd/join-cmd.py @@ -8,6 +8,7 @@ optspec = """ bup join [-r host:path] [refs or hashes...] -- r,remote= remote repository path +o= output filename """ o = options.Options(optspec) (opt, flags, extra) = o.parse(sys.argv[1:]) @@ -26,12 +27,17 @@ else: cp = git.CatPipe() cat = cp.join +if opt.o: + outfile = open(opt.o, 'wb') +else: + outfile = sys.stdout + for id in extra: try: for blob in cat(id): - sys.stdout.write(blob) + outfile.write(blob) except KeyError, e: - sys.stdout.flush() + outfile.flush() log('error: %s\n' % e) ret = 1 diff --git a/t/test.sh b/t/test.sh index 2142471..878dbb5 100755 --- a/t/test.sh +++ b/t/test.sh @@ -166,7 +166,7 @@ WVPASS bup memtest -c1 -n100 --existing WVSTART "join" WVPASS bup join $(cat tags1.tmp) >out1.tmp WVPASS bup join out2.tmp -WVPASS bup join out2t.tmp +WVPASS bup join out2c.tmp WVPASS bup join -r ":$BUP_DIR" out2c.tmp WVPASS diff -u t/testfile1 out1.tmp