3 test_description
='filter-branch removal of trees with null sha1'
7 test_expect_success
'setup: base commits' '
13 test_expect_success
'setup: a commit with a bogus null sha1 in the tree' '
16 printf "160000 commit $ZERO_OID\\tbroken\\n"
18 echo "add broken entry" >msg &&
20 tree=$(git mktree <broken-tree) &&
22 commit=$(git commit-tree $tree -p HEAD <msg) &&
23 git update-ref HEAD "$commit"
26 # we have to make one more commit on top removing the broken
27 # entry, since otherwise our index does not match HEAD (and filter-branch will
28 # complain). We could make the index match HEAD, but doing so would involve
29 # writing a null sha1 into the index.
30 test_expect_success
'setup: bring HEAD and index in sync' '
32 git commit -a -m "back to normal"
35 test_expect_success
'noop filter-branch complains' '
36 test_must_fail git filter-branch \
37 --force --prune-empty \
41 test_expect_success
'filter commands are still checked' '
42 test_must_fail git filter-branch \
43 --force --prune-empty \
44 --index-filter "git rm --cached --ignore-unmatch three.t"
47 test_expect_success
'removing the broken entry works' '
50 --force --prune-empty \
51 --index-filter "git rm --cached --ignore-unmatch broken" &&
52 git log -1 --format=%s >actual &&
53 test_cmp expect actual