3 # Copyright (c) 2005 Amos Waterland
4 # Copyright (c) 2006 Christian Couder
7 test_description='git pack-refs should not change the branch semantic
9 This test runs git pack-refs and git show-ref and checks that the branch
10 semantic is still the same.
14 echo '[core] logallrefupdates = true' >>.git/config
17 'prepare a trivial repository' \
19 git update-index --add A &&
20 git commit -m "Initial commit." &&
21 HEAD=$(git rev-parse --verify HEAD)'
26 'see if git show-ref works as expected' \
28 SHA1=`cat .git/refs/heads/a` &&
29 echo "$SHA1 refs/heads/a" >expect &&
30 git show-ref a >result &&
31 test_cmp expect result'
34 'see if a branch still exists when packed' \
36 git pack-refs --all &&
37 rm -f .git/refs/heads/b &&
38 echo "$SHA1 refs/heads/b" >expect &&
39 git show-ref b >result &&
40 test_cmp expect result'
42 test_expect_success 'git branch c/d should barf if branch c exists' '
44 git pack-refs --all &&
45 rm -f .git/refs/heads/c &&
46 test_must_fail git branch c/d
50 'see if a branch still exists after git pack-refs --prune' \
52 git pack-refs --all --prune &&
53 echo "$SHA1 refs/heads/e" >expect &&
54 git show-ref e >result &&
55 test_cmp expect result'
57 test_expect_success 'see if git pack-refs --prune remove ref files' '
59 git pack-refs --all --prune &&
60 ! test -f .git/refs/heads/f
64 'git branch g should work when git branch g/h has been deleted' \
66 git pack-refs --all --prune &&
69 git pack-refs --all &&
72 test_expect_success 'git branch i/j/k should barf if branch i exists' '
74 git pack-refs --all --prune &&
75 test_must_fail git branch i/j/k
79 'test git branch k after branch k/l/m and k/lm have been deleted' \
84 git branch -d k/l/m &&
89 'test git branch n after some branch deletion and pruning' \
95 git pack-refs --all --prune &&
96 git branch -d n/o/p &&
100 'see if up-to-date packed refs are preserved' \
102 git pack-refs --all --prune &&
103 git update-ref refs/heads/q refs/heads/q &&
104 ! test -f .git/refs/heads/q'
106 test_expect_success 'pack, prune and repack' '
108 git pack-refs --all --prune &&
109 git show-ref >all-of-them &&
111 git show-ref >again &&
112 test_cmp all-of-them again