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