api-run-command.txt: typofix
[git/dscho.git] / t / t7701-repack-unpack-unreachable.sh
blob6a5211f1873be6a8bb80404cda34751c46f26e86
1 #!/bin/sh
3 test_description='git-repack works correctly'
5 . ./test-lib.sh
7 test_expect_success '-A option leaves unreachable objects unpacked' '
8 echo content > file1 &&
9 git add . &&
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 &&
24 # pack the repo
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) &&
30 git show $fsha1 &&
31 git show $csha1 &&
32 git show $tsha1 &&
33 # now expire the reflog
34 sleep 1 &&
35 git reflog expire --expire-unreachable=now --all &&
36 # and repack
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) &&
42 git show $fsha1 &&
43 git show $csha1 &&
44 git show $tsha1
47 test_done