Commit | Line | Data |
---|---|---|
919a3c98 CC |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2005 Amos Waterland | |
4 | # Copyright (c) 2006 Christian Couder | |
5 | # | |
6 | ||
7 | test_description='git pack-refs should not change the branch semantic | |
8 | ||
9 | This test runs git pack-refs and git show-ref and checks that the branch | |
10 | semantic is still the same. | |
11 | ' | |
12 | . ./test-lib.sh | |
13 | ||
3b463c3f JH |
14 | echo '[core] logallrefupdates = true' >>.git/config |
15 | ||
919a3c98 CC |
16 | test_expect_success \ |
17 | 'prepare a trivial repository' \ | |
18 | 'echo Hello > A && | |
5be60078 | 19 | git update-index --add A && |
919a3c98 | 20 | git-commit -m "Initial commit." && |
5be60078 | 21 | HEAD=$(git rev-parse --verify HEAD)' |
919a3c98 CC |
22 | |
23 | SHA1= | |
24 | ||
25 | test_expect_success \ | |
26 | 'see if git show-ref works as expected' \ | |
5be60078 | 27 | 'git branch a && |
26e5fc34 | 28 | SHA1=`cat .git/refs/heads/a` && |
919a3c98 | 29 | echo "$SHA1 refs/heads/a" >expect && |
5be60078 | 30 | git show-ref a >result && |
919a3c98 CC |
31 | diff expect result' |
32 | ||
33 | test_expect_success \ | |
34 | 'see if a branch still exists when packed' \ | |
5be60078 JH |
35 | 'git branch b && |
36 | git pack-refs --all && | |
0f018bab | 37 | rm -f .git/refs/heads/b && |
919a3c98 | 38 | echo "$SHA1 refs/heads/b" >expect && |
5be60078 | 39 | git show-ref b >result && |
919a3c98 CC |
40 | diff expect result' |
41 | ||
fc12f082 CC |
42 | test_expect_failure \ |
43 | 'git branch c/d should barf if branch c exists' \ | |
5be60078 JH |
44 | 'git branch c && |
45 | git pack-refs --all && | |
fc12f082 | 46 | rm .git/refs/heads/c && |
5be60078 | 47 | git branch c/d' |
919a3c98 CC |
48 | |
49 | test_expect_success \ | |
50 | 'see if a branch still exists after git pack-refs --prune' \ | |
5be60078 JH |
51 | 'git branch e && |
52 | git pack-refs --all --prune && | |
919a3c98 | 53 | echo "$SHA1 refs/heads/e" >expect && |
5be60078 | 54 | git show-ref e >result && |
919a3c98 CC |
55 | diff expect result' |
56 | ||
57 | test_expect_failure \ | |
58 | 'see if git pack-refs --prune remove ref files' \ | |
5be60078 JH |
59 | 'git branch f && |
60 | git pack-refs --all --prune && | |
919a3c98 CC |
61 | ls .git/refs/heads/f' |
62 | ||
63 | test_expect_success \ | |
64 | 'git branch g should work when git branch g/h has been deleted' \ | |
5be60078 JH |
65 | 'git branch g/h && |
66 | git pack-refs --all --prune && | |
67 | git branch -d g/h && | |
68 | git branch g && | |
69 | git pack-refs --all && | |
70 | git branch -d g' | |
919a3c98 | 71 | |
14c8a681 CC |
72 | test_expect_failure \ |
73 | 'git branch i/j/k should barf if branch i exists' \ | |
5be60078 JH |
74 | 'git branch i && |
75 | git pack-refs --all --prune && | |
76 | git branch i/j/k' | |
14c8a681 CC |
77 | |
78 | test_expect_success \ | |
79 | 'test git branch k after branch k/l/m and k/lm have been deleted' \ | |
5be60078 JH |
80 | 'git branch k/l && |
81 | git branch k/lm && | |
82 | git branch -d k/l && | |
83 | git branch k/l/m && | |
84 | git branch -d k/l/m && | |
85 | git branch -d k/lm && | |
86 | git branch k' | |
14c8a681 CC |
87 | |
88 | test_expect_success \ | |
89 | 'test git branch n after some branch deletion and pruning' \ | |
5be60078 JH |
90 | 'git branch n/o && |
91 | git branch n/op && | |
92 | git branch -d n/o && | |
93 | git branch n/o/p && | |
94 | git branch -d n/op && | |
95 | git pack-refs --all --prune && | |
96 | git branch -d n/o/p && | |
97 | git branch n' | |
14c8a681 | 98 | |
1b555932 LT |
99 | test_expect_success 'pack, prune and repack' ' |
100 | git-tag foo && | |
5be60078 JH |
101 | git pack-refs --all --prune && |
102 | git show-ref >all-of-them && | |
103 | git pack-refs && | |
104 | git show-ref >again && | |
1b555932 LT |
105 | diff all-of-them again |
106 | ' | |
107 | ||
919a3c98 | 108 | test_done |