3 test_description
='git-repack works correctly'
7 test_expect_success
'-A option leaves unreachable objects unpacked' '
8 echo content > file1 &&
10 git commit -m initial_commit &&
11 # create a transient branch with unique content
12 git checkout -b transient_branch &&
13 echo more content >> file1 &&
14 # record the objects created in the database for file, commit, tree
15 fsha1=$(git hash-object file1) &&
16 git commit -a -m more_content &&
17 csha1=$(git rev-parse HEAD^{commit}) &&
18 tsha1=$(git rev-parse HEAD^{tree}) &&
19 git checkout master &&
20 echo even more content >> file1 &&
21 git commit -a -m even_more_content &&
22 # delete the transient branch
23 git branch -D transient_branch &&
25 git repack -A -d -l &&
26 # verify objects are packed in repository
27 test 3 = $(git verify-pack -v -- .git/objects/pack/*.idx |
28 grep -e "^$fsha1 " -e "^$csha1 " -e "^$tsha1 " |
29 sort | uniq | wc -l) &&
33 # now expire the reflog
35 git reflog expire --expire-unreachable=now --all &&
37 git repack -A -d -l &&
38 # verify objects are retained unpacked
39 test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx |
40 grep -e "^$fsha1 " -e "^$csha1 " -e "^$tsha1 " |
41 sort | uniq | wc -l) &&