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