Guilt v0.37-rc1
[guilt.git] / regression / t-061.sh
blobbda50c7b762597f06a1f94d75c8658c95aa183ad
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 >/dev/null; then
19 cmd git checkout guilt/master
20 else
21 cmd git checkout master
23 cmd guilt pop -a
24 cmd git branch -d $1
25 cmd rm -r .git/patches/$1
26 cmd git for-each-ref
27 cmd list_files
30 function fixup_time_info
32 touch -a -m -t "$TOUCH_DATE" ".git/patches/master/$1"
35 cmd setup_repo
37 cmd guilt push -a
38 cmd list_files
39 cmd git for-each-ref
41 # Pop and push patches. Check that the repo is converted to new-style
42 # refs when no patches are applied and a patch is pushed.
43 old_style_branch master
44 cmd git for-each-ref
46 cmd list_files
48 for i in `seq 5`; do
49 if [ $i -ge 5 ]; then
50 shouldfail guilt pop
51 else
52 cmd guilt pop
54 cmd git for-each-ref
55 cmd guilt push
56 cmd git for-each-ref
57 cmd guilt pop
58 cmd git for-each-ref
59 done
61 # Check that "pop -a" does the right thing.
62 cmd guilt push -a
64 old_style_branch master
66 cmd git for-each-ref
68 cmd guilt pop -a
70 cmd git for-each-ref
72 # Check that pushing two patches converts the repo to now-style (since
73 # it currently has no patches applied).
74 cmd guilt push add
75 cmd git for-each-ref
77 # Check guilt branch with a few patches applied.
78 old_style_branch master
79 cmd guilt branch topic
80 cmd git for-each-ref
82 # Check that the topic branch is converted to new-style.
83 cmd guilt pop -a
84 cmd guilt push
85 cmd git for-each-ref
87 remove_topic topic
89 # Check guilt branch with the full patch series applied.
90 cmd guilt push -a
91 old_style_branch master
92 cmd guilt branch topic
93 cmd git for-each-ref
95 remove_topic topic
97 # Check guilt branch with no patches applied.
98 # This gives us a new-style checkout.
99 cmd guilt branch topic
100 cmd git for-each-ref
101 cmd list_files
103 remove_topic topic
105 # Check guilt branch in a new-style directory with all patches
106 # applied. (Strictly speaking, this test should probably move to a
107 # file devoted to testing "guilt branch".)
108 cmd guilt push -a
109 cmd guilt branch topic
110 cmd git for-each-ref
111 cmd list_files
112 cmd guilt pop -a
113 cmd git for-each-ref
115 remove_topic topic
117 # Check that "guilt new" does the right thing when no patches are
118 # applied. (Strictly speaking, this test should maybe move to
119 # t-025.sh).
121 cmd guilt new newpatch
122 cmd git for-each-ref '--format=%(refname)'
123 cmd guilt pop
124 fixup_time_info newpatch
125 cmd guilt push
126 cmd git for-each-ref
128 # Check that "guilt commit" does the right thing when committing all
129 # applied patches. (Strictly speaking, this test should maybe move to
130 # t-030.sh).
131 cmd git branch
132 cmd guilt applied
133 cmd guilt commit -a
134 cmd git for-each-ref
135 cmd git branch
137 # Check that "guilt commit" does the right thing when committing only
138 # a few of the applied patches. (Strictly speaking, this test should
139 # maybe move to t-030.sh).
140 cmd guilt push -a
141 cmd guilt applied
142 cmd git branch
143 cmd git for-each-ref
144 cmd guilt commit -n 2
145 cmd git for-each-ref
146 cmd git branch
147 cmd guilt commit -n 2
148 cmd git for-each-ref
149 cmd git branch
150 cmd guilt series