]> arthur.barton.de Git - bup.git/commitdiff
cmd/join: add a new -o (output filename) option.
authorAvery Pennarun <apenwarr@gmail.com>
Sun, 13 Feb 2011 06:53:50 +0000 (22:53 -0800)
committerAvery Pennarun <apenwarr@gmail.com>
Sun, 13 Feb 2011 06:53:50 +0000 (22:53 -0800)
This is a helpful way to have it open and write to the given output file.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
cmd/join-cmd.py
t/test.sh

index edc5fcb216338ecda6c1dcdc133c146f9fe97ec7..042b4023de5af8ad4cd8425e96292d7346d6fc36 100755 (executable)
@@ -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
 
index 2142471e962cde94c2951c58e9eea76809df6680..878dbb568cd670f8f471c2062ef956ae8afec330 100755 (executable)
--- 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 <tags2.tmp >out2.tmp
-WVPASS bup join <tags2t.tmp >out2t.tmp
+WVPASS bup join <tags2t.tmp -o out2t.tmp
 WVPASS bup join -r "$BUP_DIR" <tags2c.tmp >out2c.tmp
 WVPASS bup join -r ":$BUP_DIR" <tags2c.tmp >out2c.tmp
 WVPASS diff -u t/testfile1 out1.tmp