Merge branch 'sr/local-config'
[git/jnareb-git/bp-gitweb.git] / t / t6016-rev-list-graph-simplify-history.sh
blob27fd52b7be8ee8a084bc96bd606813cc556c4bb0
1 #!/bin/sh
3 # There's more than one "correct" way to represent the history graphically.
4 # These tests depend on the current behavior of the graphing code. If the
5 # graphing code is ever changed to draw the output differently, these tests
6 # cases will need to be updated to know about the new layout.
8 test_description='--graph and simplified history'
10 . ./test-lib.sh
12 test_expect_success 'set up rev-list --graph test' '
13 # 3 commits on branch A
14 test_commit A1 foo.txt &&
15 test_commit A2 bar.txt &&
16 test_commit A3 bar.txt &&
17 git branch -m master A &&
19 # 2 commits on branch B, started from A1
20 git checkout -b B A1 &&
21 test_commit B1 foo.txt &&
22 test_commit B2 abc.txt &&
24 # 2 commits on branch C, started from A2
25 git checkout -b C A2 &&
26 test_commit C1 xyz.txt &&
27 test_commit C2 xyz.txt &&
29 # Octopus merge B and C into branch A
30 git checkout A &&
31 git merge B C &&
32 git tag A4
34 test_commit A5 bar.txt &&
36 # More commits on C, then merge C into A
37 git checkout C &&
38 test_commit C3 foo.txt &&
39 test_commit C4 bar.txt &&
40 git checkout A &&
41 git merge -s ours C &&
42 git tag A6
44 test_commit A7 bar.txt &&
46 # Store commit names in variables for later use
47 A1=$(git rev-parse --verify A1) &&
48 A2=$(git rev-parse --verify A2) &&
49 A3=$(git rev-parse --verify A3) &&
50 A4=$(git rev-parse --verify A4) &&
51 A5=$(git rev-parse --verify A5) &&
52 A6=$(git rev-parse --verify A6) &&
53 A7=$(git rev-parse --verify A7) &&
54 B1=$(git rev-parse --verify B1) &&
55 B2=$(git rev-parse --verify B2) &&
56 C1=$(git rev-parse --verify C1) &&
57 C2=$(git rev-parse --verify C2) &&
58 C3=$(git rev-parse --verify C3) &&
59 C4=$(git rev-parse --verify C4)
62 test_expect_success '--graph --all' '
63 rm -f expected &&
64 echo "* $A7" >> expected &&
65 echo "* $A6" >> expected &&
66 echo "|\\ " >> expected &&
67 echo "| * $C4" >> expected &&
68 echo "| * $C3" >> expected &&
69 echo "* | $A5" >> expected &&
70 echo "| | " >> expected &&
71 echo "| \\ " >> expected &&
72 echo "*-. \\ $A4" >> expected &&
73 echo "|\\ \\ \\ " >> expected &&
74 echo "| | |/ " >> expected &&
75 echo "| | * $C2" >> expected &&
76 echo "| | * $C1" >> expected &&
77 echo "| * | $B2" >> expected &&
78 echo "| * | $B1" >> expected &&
79 echo "* | | $A3" >> expected &&
80 echo "| |/ " >> expected &&
81 echo "|/| " >> expected &&
82 echo "* | $A2" >> expected &&
83 echo "|/ " >> expected &&
84 echo "* $A1" >> expected &&
85 git rev-list --graph --all > actual &&
86 test_cmp expected actual
89 # Make sure the graph_is_interesting() code still realizes
90 # that undecorated merges are interesting, even with --simplify-by-decoration
91 test_expect_success '--graph --simplify-by-decoration' '
92 rm -f expected &&
93 git tag -d A4
94 echo "* $A7" >> expected &&
95 echo "* $A6" >> expected &&
96 echo "|\\ " >> expected &&
97 echo "| * $C4" >> expected &&
98 echo "| * $C3" >> expected &&
99 echo "* | $A5" >> expected &&
100 echo "| | " >> expected &&
101 echo "| \\ " >> expected &&
102 echo "*-. \\ $A4" >> expected &&
103 echo "|\\ \\ \\ " >> expected &&
104 echo "| | |/ " >> expected &&
105 echo "| | * $C2" >> expected &&
106 echo "| | * $C1" >> expected &&
107 echo "| * | $B2" >> expected &&
108 echo "| * | $B1" >> expected &&
109 echo "* | | $A3" >> expected &&
110 echo "| |/ " >> expected &&
111 echo "|/| " >> expected &&
112 echo "* | $A2" >> expected &&
113 echo "|/ " >> expected &&
114 echo "* $A1" >> expected &&
115 git rev-list --graph --all --simplify-by-decoration > actual &&
116 test_cmp expected actual
119 # Get rid of all decorations on branch B, and graph with it simplified away
120 test_expect_success '--graph --simplify-by-decoration prune branch B' '
121 rm -f expected &&
122 git tag -d B2
123 git tag -d B1
124 git branch -d B
125 echo "* $A7" >> expected &&
126 echo "* $A6" >> expected &&
127 echo "|\\ " >> expected &&
128 echo "| * $C4" >> expected &&
129 echo "| * $C3" >> expected &&
130 echo "* | $A5" >> expected &&
131 echo "* | $A4" >> expected &&
132 echo "|\\ \\ " >> expected &&
133 echo "| |/ " >> expected &&
134 echo "| * $C2" >> expected &&
135 echo "| * $C1" >> expected &&
136 echo "* | $A3" >> expected &&
137 echo "|/ " >> expected &&
138 echo "* $A2" >> expected &&
139 echo "* $A1" >> expected &&
140 git rev-list --graph --simplify-by-decoration --all > actual &&
141 test_cmp expected actual
144 test_expect_success '--graph --full-history -- bar.txt' '
145 rm -f expected &&
146 git tag -d B2
147 git tag -d B1
148 git branch -d B
149 echo "* $A7" >> expected &&
150 echo "* $A6" >> expected &&
151 echo "|\\ " >> expected &&
152 echo "| * $C4" >> expected &&
153 echo "* | $A5" >> expected &&
154 echo "* | $A4" >> expected &&
155 echo "|\\ \\ " >> expected &&
156 echo "| |/ " >> expected &&
157 echo "* | $A3" >> expected &&
158 echo "|/ " >> expected &&
159 echo "* $A2" >> expected &&
160 git rev-list --graph --full-history --all -- bar.txt > actual &&
161 test_cmp expected actual
164 test_expect_success '--graph --full-history --simplify-merges -- bar.txt' '
165 rm -f expected &&
166 git tag -d B2
167 git tag -d B1
168 git branch -d B
169 echo "* $A7" >> expected &&
170 echo "* $A6" >> expected &&
171 echo "|\\ " >> expected &&
172 echo "| * $C4" >> expected &&
173 echo "* | $A5" >> expected &&
174 echo "* | $A3" >> expected &&
175 echo "|/ " >> expected &&
176 echo "* $A2" >> expected &&
177 git rev-list --graph --full-history --simplify-merges --all \
178 -- bar.txt > actual &&
179 test_cmp expected actual
182 test_expect_success '--graph -- bar.txt' '
183 rm -f expected &&
184 git tag -d B2
185 git tag -d B1
186 git branch -d B
187 echo "* $A7" >> expected &&
188 echo "* $A5" >> expected &&
189 echo "* $A3" >> expected &&
190 echo "| * $C4" >> expected &&
191 echo "|/ " >> expected &&
192 echo "* $A2" >> expected &&
193 git rev-list --graph --all -- bar.txt > actual &&
194 test_cmp expected actual
197 test_expect_success '--graph --sparse -- bar.txt' '
198 rm -f expected &&
199 git tag -d B2
200 git tag -d B1
201 git branch -d B
202 echo "* $A7" >> expected &&
203 echo "* $A6" >> expected &&
204 echo "* $A5" >> expected &&
205 echo "* $A4" >> expected &&
206 echo "* $A3" >> expected &&
207 echo "| * $C4" >> expected &&
208 echo "| * $C3" >> expected &&
209 echo "| * $C2" >> expected &&
210 echo "| * $C1" >> expected &&
211 echo "|/ " >> expected &&
212 echo "* $A2" >> expected &&
213 echo "* $A1" >> expected &&
214 git rev-list --graph --sparse --all -- bar.txt > actual &&
215 test_cmp expected actual
218 test_expect_success '--graph ^C4' '
219 rm -f expected &&
220 echo "* $A7" >> expected &&
221 echo "* $A6" >> expected &&
222 echo "* $A5" >> expected &&
223 echo "* $A4" >> expected &&
224 echo "|\\ " >> expected &&
225 echo "| * $B2" >> expected &&
226 echo "| * $B1" >> expected &&
227 echo "* $A3" >> expected &&
228 git rev-list --graph --all ^C4 > actual &&
229 test_cmp expected actual
232 test_expect_success '--graph ^C3' '
233 rm -f expected &&
234 echo "* $A7" >> expected &&
235 echo "* $A6" >> expected &&
236 echo "|\\ " >> expected &&
237 echo "| * $C4" >> expected &&
238 echo "* $A5" >> expected &&
239 echo "* $A4" >> expected &&
240 echo "|\\ " >> expected &&
241 echo "| * $B2" >> expected &&
242 echo "| * $B1" >> expected &&
243 echo "* $A3" >> expected &&
244 git rev-list --graph --all ^C3 > actual &&
245 test_cmp expected actual
248 # I don't think the ordering of the boundary commits is really
249 # that important, but this test depends on it. If the ordering ever changes
250 # in the code, we'll need to update this test.
251 test_expect_success '--graph --boundary ^C3' '
252 rm -f expected &&
253 echo "* $A7" >> expected &&
254 echo "* $A6" >> expected &&
255 echo "|\\ " >> expected &&
256 echo "| * $C4" >> expected &&
257 echo "* | $A5" >> expected &&
258 echo "| | " >> expected &&
259 echo "| \\ " >> expected &&
260 echo "*-. \\ $A4" >> expected &&
261 echo "|\\ \\ \\ " >> expected &&
262 echo "| * | | $B2" >> expected &&
263 echo "| * | | $B1" >> expected &&
264 echo "* | | | $A3" >> expected &&
265 echo "o | | | $A2" >> expected &&
266 echo "|/ / / " >> expected &&
267 echo "o | | $A1" >> expected &&
268 echo " / / " >> expected &&
269 echo "| o $C3" >> expected &&
270 echo "|/ " >> expected &&
271 echo "o $C2" >> expected &&
272 git rev-list --graph --boundary --all ^C3 > actual &&
273 test_cmp expected actual
276 test_done