]> arthur.barton.de Git - bup.git/commitdiff
'bup split' now outputs any combination of blobs, tree, and commit.
authorAvery Pennarun <apenwarr@gmail.com>
Thu, 31 Dec 2009 23:35:55 +0000 (18:35 -0500)
committerAvery Pennarun <apenwarr@gmail.com>
Thu, 31 Dec 2009 23:35:55 +0000 (18:35 -0500)
maximum flexibility.

Makefile
cmd-split.py

index 7138e851c23cac4d5a47903c27098d49f85d3508..ae2924baa60742559da6cfbbd90af452edfdbbb2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -14,8 +14,8 @@ runtests: all
        
 runtests-cmdline: all
        @echo "Testing \"$@\" in Makefile:"
-       ./bup split <testfile1 >tags1
-       ./bup split <testfile2 >tags2
+       ./bup split -b <testfile1 >tags1
+       ./bup split -b <testfile2 >tags2
        diff -u tags1 tags2 || true
        wc -c testfile1 testfile2
        wc -l tags1 tags2
index 5a2f9670ecde373b7a4326f269823a18e8babeea..e5eb5c3a1f6f3a53e4e2552495031440e48c97a7 100755 (executable)
@@ -77,12 +77,19 @@ def hashsplit_iter(f):
 optspec = """
 bup split [-t] <filename
 --
-t,tree     output a tree instead of a series of blobs
-c,commit   output a commit instead of a tree or blobs
+b,blobs    output a series of blob ids
+t,tree     output a tree id
+c,commit   output a commit id
 n,name=    name of backup set to update (if any)
 bench      print benchmark timings to stderr
 """
-(opt, flags, extra) = options.Options('bup split', optspec).parse(sys.argv[1:])
+o = options.Options('bup split', optspec)
+(opt, flags, extra) = o.parse(sys.argv[1:])
+
+if not (opt.blobs or opt.tree or opt.commit or opt.name):
+    log("bup split: use one or more of -b, -t, -c, -n\n")
+    o.usage()
+
 
 start_time = time.time()
 shalist = []
@@ -90,18 +97,18 @@ shalist = []
 ofs = 0
 for (ofs, size, sha) in hashsplit_iter(sys.stdin):
     #log('SPLIT @ %-8d size=%-8d\n' % (ofs, size))
-    if not opt.tree and not opt.commit:
+    if opt.blobs:
         print sha
     shalist.append(('100644', '%016x.bupchunk' % ofs, sha))
-if opt.tree or opt.commit:
-    tree = git.gen_tree(shalist)
-if opt.commit:
+tree = git.gen_tree(shalist)
+if opt.tree:
+    print tree
+if opt.commit or opt.name:
     msg = 'Generated by command:\n%r' % sys.argv
     ref = opt.name and ('refs/heads/%s' % opt.name) or None
     commit = git.gen_commit_easy(ref, tree, msg)
-    print commit
-elif opt.tree:
-    print tree
+    if opt.commit:
+        print commit
 
 secs = time.time() - start_time
 if opt.bench: