list-objects-filter: don't memset after releasing filter struct
[git/debian.git] / t / t7008-filter-branch-null-sha1.sh
blob93fbc92b8dbc297512050846c4f00ec803dea4a9
1 #!/bin/sh
3 test_description='filter-branch removal of trees with null sha1'
5 . ./test-lib.sh
7 test_expect_success 'setup: base commits' '
8 test_commit one &&
9 test_commit two &&
10 test_commit three
13 test_expect_success 'setup: a commit with a bogus null sha1 in the tree' '
15 git ls-tree HEAD &&
16 printf "160000 commit $ZERO_OID\\tbroken\\n"
17 } >broken-tree &&
18 echo "add broken entry" >msg &&
20 tree=$(git mktree <broken-tree) &&
21 test_tick &&
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' '
31 test_tick &&
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 \
38 --index-filter "true"
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' '
48 echo three >expect &&
49 git filter-branch \
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
56 test_done