2 . ./wvtest-bup.sh || exit $?
3 . ./t/lib.sh || exit $?
7 top="$(WVPASS pwd)" || exit $?
8 tmpdir="$(WVPASS wvmktempdir)" || exit $?
10 export BUP_DIR="$tmpdir/bup"
11 export GIT_DIR="$tmpdir/bup"
13 bup() { "$top/bup" "$@"; }
14 compare-trees() { "$top/t/compare-trees" "$@"; }
20 WVPASS mkdir src src/foo
22 WVPASS bup random 1k > src/baz
23 WVPASS bup on - index src
24 WVPASS bup on - save -ctn src src > get.log
25 WVPASSEQ $(WVPASS cat get.log | WVPASS wc -l) 2
26 tree_id=$(WVPASS awk 'FNR == 1' get.log) || exit $?
27 commit_id=$(WVPASS awk 'FNR == 2' get.log) || exit $?
28 WVPASS git ls-tree "$tree_id"
29 WVPASS git cat-file commit "$commit_id" | head -n 1 \
30 | WVPASS grep "^tree $tree_id\$"
32 WVPASS bup restore -C restore "src/latest/$(pwd)/src/."
33 WVPASS compare-trees src/ restore/
37 WVPASS bup on - split -ctn baz src/baz > get.log
38 tree_id=$(WVPASS awk 'FNR == 1' get.log) || exit $?
39 commit_id=$(WVPASS awk 'FNR == 2' get.log) || exit $?
40 WVPASS git ls-tree "$tree_id"
41 WVPASS git cat-file commit "$commit_id" | head -n 1 \
42 | WVPASS grep "^tree $tree_id\$"
43 WVPASS bup join baz > restore-baz
44 WVPASS cmp src/baz restore-baz
47 # the 'a-zA-Z0-9_' is '\w' from python,
48 # the trailing _ is because there's no dir specified
49 # and that should thus be empty
50 hostname=$(bup python -c "from bup import helpers ; print(helpers.hostname().decode('iso8859-1'))")
51 idxcache=$(echo "$hostname" | sed 's/[^@a-zA-Z0-9_]/_/g')_
52 # there should be an index-cache now
53 for idx in "$tmpdir"/bup/objects/pack/*.idx ; do
54 cachedidx="$tmpdir/bup/index-cache/$idxcache/$(basename "$idx")"
55 WVPASS cmp "$idx" "$cachedidx"
58 WVPASS rm -rf "$tmpdir"