3 test_description='filter-branch removal of trees with null sha1'
6 test_expect_success 'setup: base commits' '
12 test_expect_success 'setup: a commit with a bogus null sha1 in the tree' '
15 printf "160000 commit $_z40\\tbroken\\n"
17 echo "add broken entry" >msg &&
19 tree=$(git mktree <broken-tree) &&
21 commit=$(git commit-tree $tree -p HEAD <msg) &&
22 git update-ref HEAD "$commit"
25 # we have to make one more commit on top removing the broken
26 # entry, since otherwise our index does not match HEAD (and filter-branch will
27 # complain). We could make the index match HEAD, but doing so would involve
28 # writing a null sha1 into the index.
29 test_expect_success 'setup: bring HEAD and index in sync' '
31 git commit -a -m "back to normal"
34 test_expect_success 'filter commands are still checked' '
35 test_must_fail git filter-branch \
36 --force --prune-empty \
37 --index-filter "git rm --cached --ignore-unmatch three.t"
40 test_expect_success 'removing the broken entry works' '
43 --force --prune-empty \
44 --index-filter "git rm --cached --ignore-unmatch broken" &&
45 git log -1 --format=%s >actual &&
46 test_cmp expect actual