]>
Commit | Line | Data |
---|---|---|
b97c470b AS |
1 | #!/bin/sh |
2 | ||
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. | |
7 | ||
8 | test_description='--graph and simplified history' | |
9 | ||
1550bb6e | 10 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
11 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
12 | ||
b97c470b | 13 | . ./test-lib.sh |
c8302c6c AR |
14 | . "$TEST_DIRECTORY"/lib-log-graph.sh |
15 | ||
16 | check_graph () { | |
17 | cat >expect && | |
18 | lib_test_cmp_graph --format=%s "$@" | |
19 | } | |
b97c470b AS |
20 | |
21 | test_expect_success 'set up rev-list --graph test' ' | |
22 | # 3 commits on branch A | |
23 | test_commit A1 foo.txt && | |
24 | test_commit A2 bar.txt && | |
25 | test_commit A3 bar.txt && | |
1550bb6e | 26 | git branch -m main A && |
b97c470b AS |
27 | |
28 | # 2 commits on branch B, started from A1 | |
29 | git checkout -b B A1 && | |
30 | test_commit B1 foo.txt && | |
31 | test_commit B2 abc.txt && | |
32 | ||
33 | # 2 commits on branch C, started from A2 | |
34 | git checkout -b C A2 && | |
35 | test_commit C1 xyz.txt && | |
36 | test_commit C2 xyz.txt && | |
37 | ||
38 | # Octopus merge B and C into branch A | |
39 | git checkout A && | |
c8302c6c | 40 | git merge B C -m A4 && |
e6f68a2e | 41 | git tag A4 && |
b97c470b AS |
42 | |
43 | test_commit A5 bar.txt && | |
44 | ||
45 | # More commits on C, then merge C into A | |
46 | git checkout C && | |
47 | test_commit C3 foo.txt && | |
48 | test_commit C4 bar.txt && | |
49 | git checkout A && | |
c8302c6c | 50 | git merge -s ours C -m A6 && |
e6f68a2e | 51 | git tag A6 && |
b97c470b | 52 | |
c8302c6c AR |
53 | test_commit A7 bar.txt |
54 | ' | |
b97c470b AS |
55 | |
56 | test_expect_success '--graph --all' ' | |
c8302c6c AR |
57 | check_graph --all <<-\EOF |
58 | * A7 | |
59 | * A6 | |
60 | |\ | |
61 | | * C4 | |
62 | | * C3 | |
63 | * | A5 | |
64 | | | | |
65 | | \ | |
66 | *-. | A4 | |
67 | |\ \| | |
68 | | | * C2 | |
69 | | | * C1 | |
70 | | * | B2 | |
71 | | * | B1 | |
72 | * | | A3 | |
73 | | |/ | |
74 | |/| | |
75 | * | A2 | |
76 | |/ | |
77 | * A1 | |
78 | EOF | |
79 | ' | |
b97c470b AS |
80 | |
81 | # Make sure the graph_is_interesting() code still realizes | |
82 | # that undecorated merges are interesting, even with --simplify-by-decoration | |
83 | test_expect_success '--graph --simplify-by-decoration' ' | |
e6f68a2e | 84 | git tag -d A4 && |
c8302c6c AR |
85 | check_graph --all --simplify-by-decoration <<-\EOF |
86 | * A7 | |
87 | * A6 | |
88 | |\ | |
89 | | * C4 | |
90 | | * C3 | |
91 | * | A5 | |
92 | | | | |
93 | | \ | |
94 | *-. | A4 | |
95 | |\ \| | |
96 | | | * C2 | |
97 | | | * C1 | |
98 | | * | B2 | |
99 | | * | B1 | |
100 | * | | A3 | |
101 | | |/ | |
102 | |/| | |
103 | * | A2 | |
104 | |/ | |
105 | * A1 | |
106 | EOF | |
107 | ' | |
b97c470b | 108 | |
e6f68a2e EN |
109 | test_expect_success 'setup: get rid of decorations on B' ' |
110 | git tag -d B2 && | |
111 | git tag -d B1 && | |
112 | git branch -d B | |
113 | ' | |
114 | ||
115 | # Graph with branch B simplified away | |
b97c470b | 116 | test_expect_success '--graph --simplify-by-decoration prune branch B' ' |
c8302c6c AR |
117 | check_graph --simplify-by-decoration --all <<-\EOF |
118 | * A7 | |
119 | * A6 | |
120 | |\ | |
121 | | * C4 | |
122 | | * C3 | |
123 | * | A5 | |
124 | * | A4 | |
125 | |\| | |
126 | | * C2 | |
127 | | * C1 | |
128 | * | A3 | |
129 | |/ | |
130 | * A2 | |
131 | * A1 | |
132 | EOF | |
133 | ' | |
b97c470b AS |
134 | |
135 | test_expect_success '--graph --full-history -- bar.txt' ' | |
c8302c6c AR |
136 | check_graph --full-history --all -- bar.txt <<-\EOF |
137 | * A7 | |
138 | * A6 | |
139 | |\ | |
140 | | * C4 | |
141 | * | A5 | |
142 | * | A4 | |
143 | |\| | |
144 | * | A3 | |
145 | |/ | |
146 | * A2 | |
147 | EOF | |
148 | ' | |
b97c470b AS |
149 | |
150 | test_expect_success '--graph --full-history --simplify-merges -- bar.txt' ' | |
c8302c6c AR |
151 | check_graph --full-history --simplify-merges --all -- bar.txt <<-\EOF |
152 | * A7 | |
153 | * A6 | |
154 | |\ | |
155 | | * C4 | |
156 | * | A5 | |
157 | * | A3 | |
158 | |/ | |
159 | * A2 | |
160 | EOF | |
161 | ' | |
b97c470b AS |
162 | |
163 | test_expect_success '--graph -- bar.txt' ' | |
c8302c6c AR |
164 | check_graph --all -- bar.txt <<-\EOF |
165 | * A7 | |
166 | * A5 | |
167 | * A3 | |
168 | | * C4 | |
169 | |/ | |
170 | * A2 | |
171 | EOF | |
172 | ' | |
b97c470b AS |
173 | |
174 | test_expect_success '--graph --sparse -- bar.txt' ' | |
c8302c6c AR |
175 | check_graph --sparse --all -- bar.txt <<-\EOF |
176 | * A7 | |
177 | * A6 | |
178 | * A5 | |
179 | * A4 | |
180 | * A3 | |
181 | | * C4 | |
182 | | * C3 | |
183 | | * C2 | |
184 | | * C1 | |
185 | |/ | |
186 | * A2 | |
187 | * A1 | |
188 | EOF | |
189 | ' | |
b97c470b AS |
190 | |
191 | test_expect_success '--graph ^C4' ' | |
c8302c6c AR |
192 | check_graph --all ^C4 <<-\EOF |
193 | * A7 | |
194 | * A6 | |
195 | * A5 | |
196 | * A4 | |
197 | |\ | |
198 | | * B2 | |
199 | | * B1 | |
200 | * A3 | |
201 | EOF | |
202 | ' | |
b97c470b AS |
203 | |
204 | test_expect_success '--graph ^C3' ' | |
c8302c6c AR |
205 | check_graph --all ^C3 <<-\EOF |
206 | * A7 | |
207 | * A6 | |
208 | |\ | |
209 | | * C4 | |
210 | * A5 | |
211 | * A4 | |
212 | |\ | |
213 | | * B2 | |
214 | | * B1 | |
215 | * A3 | |
216 | EOF | |
217 | ' | |
b97c470b AS |
218 | |
219 | # I don't think the ordering of the boundary commits is really | |
220 | # that important, but this test depends on it. If the ordering ever changes | |
221 | # in the code, we'll need to update this test. | |
222 | test_expect_success '--graph --boundary ^C3' ' | |
c8302c6c AR |
223 | check_graph --boundary --all ^C3 <<-\EOF |
224 | * A7 | |
225 | * A6 | |
226 | |\ | |
227 | | * C4 | |
228 | * | A5 | |
229 | | | | |
230 | | \ | |
231 | *-. \ A4 | |
232 | |\ \ \ | |
233 | | * | | B2 | |
234 | | * | | B1 | |
235 | * | | | A3 | |
236 | o | | | A2 | |
237 | |/ / / | |
238 | o / / A1 | |
239 | / / | |
240 | | o C3 | |
241 | |/ | |
242 | o C2 | |
243 | EOF | |
244 | ' | |
b97c470b AS |
245 | |
246 | test_done |