regress: setup_git_repo can assert that the repo is setup as intended
[guilt.git] / regression / t-061.sh
blob1411baab3a7838a38a9cf222ff8d63924e0be381
1 #!/bin/bash
3 # Test the branch-switching upgrade code
6 source $REG_DIR/scaffold
8 old_style_branch() {
9 # Modify the refs so that it looks as if the patch series was applied
10 # by an old version of guilt.
11 cmd git update-ref refs/heads/$1 refs/heads/guilt/$1
12 cmd git symbolic-ref HEAD refs/heads/$1
13 cmd git update-ref -d refs/heads/guilt/$1
16 remove_topic() {
17 cmd guilt pop -a
18 if git rev-parse --verify --quiet guilt/master
19 then
20 cmd git checkout guilt/master
21 else
22 cmd git checkout master
24 cmd guilt pop -a
25 cmd git branch -d $1
26 cmd rm -r .git/patches/$1
27 cmd git for-each-ref
28 cmd list_files
31 function fixup_time_info
33 touch -a -m -t "$TOUCH_DATE" ".git/patches/master/$1"
36 cmd setup_repo
38 cmd guilt push -a
39 cmd list_files
40 cmd git for-each-ref
42 # Pop and push patches. Check that the repo is converted to new-style
43 # refs when no patches are applied and a patch is pushed.
44 old_style_branch master
45 cmd git for-each-ref
47 cmd list_files
49 for i in `seq 5`
51 cmd guilt pop
52 cmd git for-each-ref
53 cmd guilt push
54 cmd git for-each-ref
55 cmd guilt pop
56 cmd git for-each-ref
57 done
59 # Check that "pop -a" does the right thing.
60 cmd guilt push -a
62 old_style_branch master
64 cmd git for-each-ref
66 cmd guilt pop -a
68 cmd git for-each-ref
70 # Check that pushing two patches converts the repo to now-style (since
71 # it currently has no patches applied).
72 cmd guilt push add
73 cmd git for-each-ref
75 # Check guilt branch with a few patches applied.
76 old_style_branch master
77 cmd guilt branch topic
78 cmd git for-each-ref
80 # Check that the topic branch is converted to new-style.
81 cmd guilt pop -a
82 cmd guilt push
83 cmd git for-each-ref
85 remove_topic topic
87 # Check guilt branch with the full patch series applied.
88 cmd guilt push -a
89 old_style_branch master
90 cmd guilt branch topic
91 cmd git for-each-ref
93 remove_topic topic
95 # Check guilt branch with no patches applied.
96 # This gives us a new-style checkout.
97 cmd guilt branch topic
98 cmd git for-each-ref
99 cmd list_files
101 remove_topic topic
103 # Check guilt branch in a new-style directory with all patches
104 # applied. (Strictly speaking, this test should probably move to a
105 # file devoted to testing "guilt branch".)
106 cmd guilt push -a
107 cmd guilt branch topic
108 cmd git for-each-ref
109 cmd list_files
110 cmd guilt pop -a
111 cmd git for-each-ref
113 remove_topic topic
115 # Check that "guilt new" does the right thing when no patches are
116 # applied. (Strictly speaking, this test should maybe move to
117 # t-025.sh).
119 cmd guilt new newpatch
120 cmd git for-each-ref '--format=%(refname)'
121 cmd guilt pop
122 fixup_time_info newpatch
123 cmd guilt push
124 cmd git for-each-ref
126 # Check that "guilt commit" does the right thing when committing all
127 # applied patches. (Strictly speaking, this test should maybe move to
128 # t-030.sh).
129 cmd git branch
130 cmd guilt applied
131 cmd guilt commit -a
132 cmd git for-each-ref
133 cmd git branch
135 # Check that "guilt commit" does the right thing when committing only
136 # a few of the applied patches. (Strictly speaking, this test should
137 # maybe move to t-030.sh).
138 cmd guilt push -a
139 cmd guilt applied
140 cmd git branch
141 cmd git for-each-ref
142 cmd guilt commit -n 2
143 cmd git for-each-ref
144 cmd git branch
145 cmd guilt commit -n 2
146 cmd git for-each-ref
147 cmd git branch
148 cmd guilt series