From cf86321f17487240e1ffaf3a54b7302ba277b1ec Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Sat, 12 Feb 2011 22:53:50 -0800 Subject: [PATCH] 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 --- cmd/join-cmd.py | 10 ++++++++-- t/test.sh | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) 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 -- 2.39.2