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