#!/usr/bin/env python
-import sys, time
+import os, sys, time
from bup import hashsplit, git, options, client
from bup.helpers import *
print sha.encode('hex')
reprogress()
elif pack_writer: # tree or commit or name
- shalist = hashsplit.split_to_shalist(pack_writer.new_blob,
- pack_writer.new_tree,
- files,
- keep_boundaries=opt.keep_boundaries,
- progress=prog)
+ if opt.name: # insert dummy_name which may be used as a restore target
+ mode, sha = \
+ hashsplit.split_to_blob_or_tree(pack_writer.new_blob,
+ pack_writer.new_tree,
+ files,
+ keep_boundaries=opt.keep_boundaries,
+ progress=prog)
+ dummy_name = git.mangle_name(os.path.basename(opt.name),
+ hashsplit.GIT_MODE_FILE, mode)
+ shalist = [(mode, dummy_name, sha)]
+ else:
+ shalist = hashsplit.split_to_shalist(
+ pack_writer.new_blob, pack_writer.new_tree, files,
+ keep_boundaries=opt.keep_boundaries, progress=prog)
tree = pack_writer.new_tree(shalist)
else:
last = 0
return _make_shalist(stacks[-1])[0]
-def split_to_blob_or_tree(makeblob, maketree, files, keep_boundaries):
+def split_to_blob_or_tree(makeblob, maketree, files,
+ keep_boundaries, progress=None):
shalist = list(split_to_shalist(makeblob, maketree,
- files, keep_boundaries))
+ files, keep_boundaries, progress))
if len(shalist) == 1:
return (shalist[0][0], shalist[0][2])
elif len(shalist) == 0:
"$(cat tagab.tmp)"
WVPASS bup split --bench -b <"$top/t/testfile1" >tags1.tmp
WVPASS bup split -vvvv -b "$top/t/testfile2" >tags2.tmp
+WVPASS echo -n "" | bup split -n split_empty_string.tmp
WVPASS bup margin
WVPASS bup midx -f
WVPASS bup midx --check -a
WVPASS diff -u "$top/t/testfile2" out2.tmp
WVPASS diff -u "$top/t/testfile2" out2t.tmp
WVPASS diff -u "$top/t/testfile2" out2c.tmp
+WVPASSEQ "$(bup join split_empty_string.tmp)" ""
WVSTART "save/git-fsck"
(
WVPASS bup restore -C buprestore.tmp "/master/latest/$tmpdir/$D/"
WVPASS touch $D/non-existent-file buprestore.tmp/non-existent-file # else diff fails
WVPASS diff -ur $D/ buprestore.tmp/
+rm -f split_empty_string.tmp
+WVPASS bup restore split_empty_string.tmp/latest/split_empty_string.tmp
+WVPASSEQ "$(cat split_empty_string.tmp)" ""
(
tmp=testrestore.tmp