James Coglan | 458152c | 2019-10-15 23:47:53 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='git log --graph of skewed merges' |
| 4 | |
Jeff King | 716a6b2 | 2023-10-03 16:27:24 -0400 | [diff] [blame] | 5 | TEST_PASSES_SANITIZE_LEAK=true |
James Coglan | 458152c | 2019-10-15 23:47:53 +0000 | [diff] [blame] | 6 | . ./test-lib.sh |
Abhishek Kumar | 989eea9 | 2020-02-24 19:08:13 +0530 | [diff] [blame] | 7 | . "$TEST_DIRECTORY"/lib-log-graph.sh |
James Coglan | 458152c | 2019-10-15 23:47:53 +0000 | [diff] [blame] | 8 | |
Denton Liu | d784d97 | 2019-11-12 10:56:22 -0800 | [diff] [blame] | 9 | check_graph () { |
| 10 | cat >expect && |
Abhishek Kumar | 989eea9 | 2020-02-24 19:08:13 +0530 | [diff] [blame] | 11 | lib_test_cmp_graph --format=%s "$@" |
Denton Liu | d784d97 | 2019-11-12 10:56:22 -0800 | [diff] [blame] | 12 | } |
| 13 | |
James Coglan | 458152c | 2019-10-15 23:47:53 +0000 | [diff] [blame] | 14 | test_expect_success 'log --graph with merge fusing with its left and right neighbors' ' |
Denton Liu | d784d97 | 2019-11-12 10:56:22 -0800 | [diff] [blame] | 15 | git checkout --orphan _p && |
| 16 | test_commit A && |
| 17 | test_commit B && |
| 18 | git checkout -b _q @^ && test_commit C && |
| 19 | git checkout -b _r @^ && test_commit D && |
| 20 | git checkout _p && git merge --no-ff _q _r -m E && |
| 21 | git checkout _r && test_commit F && |
| 22 | git checkout _p && git merge --no-ff _r -m G && |
| 23 | git checkout @^^ && git merge --no-ff _p -m H && |
| 24 | |
| 25 | check_graph <<-\EOF |
James Coglan | 458152c | 2019-10-15 23:47:53 +0000 | [diff] [blame] | 26 | * H |
| 27 | |\ |
| 28 | | * G |
| 29 | | |\ |
| 30 | | | * F |
James Coglan | 92beecc | 2019-10-15 23:47:58 +0000 | [diff] [blame] | 31 | | * | E |
| 32 | |/|\| |
James Coglan | 458152c | 2019-10-15 23:47:53 +0000 | [diff] [blame] | 33 | | | * D |
| 34 | | * | C |
| 35 | | |/ |
James Coglan | 479db18 | 2019-10-15 23:47:57 +0000 | [diff] [blame] | 36 | * / B |
James Coglan | 458152c | 2019-10-15 23:47:53 +0000 | [diff] [blame] | 37 | |/ |
| 38 | * A |
| 39 | EOF |
James Coglan | 458152c | 2019-10-15 23:47:53 +0000 | [diff] [blame] | 40 | ' |
| 41 | |
James Coglan | 0f0f389 | 2019-10-15 23:47:54 +0000 | [diff] [blame] | 42 | test_expect_success 'log --graph with left-skewed merge' ' |
Denton Liu | d784d97 | 2019-11-12 10:56:22 -0800 | [diff] [blame] | 43 | git checkout --orphan 0_p && test_commit 0_A && |
| 44 | git checkout -b 0_q 0_p && test_commit 0_B && |
| 45 | git checkout -b 0_r 0_p && |
| 46 | test_commit 0_C && |
| 47 | test_commit 0_D && |
| 48 | git checkout -b 0_s 0_p && test_commit 0_E && |
| 49 | git checkout -b 0_t 0_p && git merge --no-ff 0_r^ 0_s -m 0_F && |
| 50 | git checkout 0_p && git merge --no-ff 0_s -m 0_G && |
| 51 | git checkout @^ && git merge --no-ff 0_q 0_r 0_t 0_p -m 0_H && |
| 52 | |
| 53 | check_graph <<-\EOF |
James Coglan | 0f0f389 | 2019-10-15 23:47:54 +0000 | [diff] [blame] | 54 | *-----. 0_H |
| 55 | |\ \ \ \ |
| 56 | | | | | * 0_G |
| 57 | | |_|_|/| |
| 58 | |/| | | | |
James Coglan | 92beecc | 2019-10-15 23:47:58 +0000 | [diff] [blame] | 59 | | | | * | 0_F |
| 60 | | |_|/|\| |
| 61 | |/| | | | |
James Coglan | 0f0f389 | 2019-10-15 23:47:54 +0000 | [diff] [blame] | 62 | | | | | * 0_E |
| 63 | | |_|_|/ |
| 64 | |/| | | |
| 65 | | | * | 0_D |
| 66 | | | |/ |
| 67 | | | * 0_C |
| 68 | | |/ |
| 69 | |/| |
| 70 | | * 0_B |
| 71 | |/ |
| 72 | * 0_A |
| 73 | EOF |
James Coglan | 0f0f389 | 2019-10-15 23:47:54 +0000 | [diff] [blame] | 74 | ' |
| 75 | |
James Coglan | d62893e | 2019-10-15 23:47:55 +0000 | [diff] [blame] | 76 | test_expect_success 'log --graph with nested left-skewed merge' ' |
Denton Liu | d784d97 | 2019-11-12 10:56:22 -0800 | [diff] [blame] | 77 | git checkout --orphan 1_p && |
| 78 | test_commit 1_A && |
| 79 | test_commit 1_B && |
| 80 | test_commit 1_C && |
| 81 | git checkout -b 1_q @^ && test_commit 1_D && |
| 82 | git checkout 1_p && git merge --no-ff 1_q -m 1_E && |
| 83 | git checkout -b 1_r @~3 && test_commit 1_F && |
| 84 | git checkout 1_p && git merge --no-ff 1_r -m 1_G && |
| 85 | git checkout @^^ && git merge --no-ff 1_p -m 1_H && |
| 86 | |
| 87 | check_graph <<-\EOF |
James Coglan | d62893e | 2019-10-15 23:47:55 +0000 | [diff] [blame] | 88 | * 1_H |
| 89 | |\ |
| 90 | | * 1_G |
| 91 | | |\ |
| 92 | | | * 1_F |
| 93 | | * | 1_E |
| 94 | |/| | |
| 95 | | * | 1_D |
| 96 | * | | 1_C |
| 97 | |/ / |
James Coglan | 479db18 | 2019-10-15 23:47:57 +0000 | [diff] [blame] | 98 | * / 1_B |
James Coglan | d62893e | 2019-10-15 23:47:55 +0000 | [diff] [blame] | 99 | |/ |
| 100 | * 1_A |
| 101 | EOF |
James Coglan | d62893e | 2019-10-15 23:47:55 +0000 | [diff] [blame] | 102 | ' |
| 103 | |
| 104 | test_expect_success 'log --graph with nested left-skewed merge following normal merge' ' |
Denton Liu | d784d97 | 2019-11-12 10:56:22 -0800 | [diff] [blame] | 105 | git checkout --orphan 2_p && |
| 106 | test_commit 2_A && |
| 107 | test_commit 2_B && |
| 108 | test_commit 2_C && |
| 109 | git checkout -b 2_q @^^ && |
| 110 | test_commit 2_D && |
| 111 | test_commit 2_E && |
| 112 | git checkout -b 2_r @^ && test_commit 2_F && |
| 113 | git checkout 2_q && |
| 114 | git merge --no-ff 2_r -m 2_G && |
| 115 | git merge --no-ff 2_p^ -m 2_H && |
| 116 | git checkout -b 2_s @^^ && git merge --no-ff 2_q -m 2_J && |
| 117 | git checkout 2_p && git merge --no-ff 2_s -m 2_K && |
| 118 | |
| 119 | check_graph <<-\EOF |
James Coglan | d62893e | 2019-10-15 23:47:55 +0000 | [diff] [blame] | 120 | * 2_K |
| 121 | |\ |
| 122 | | * 2_J |
| 123 | | |\ |
| 124 | | | * 2_H |
| 125 | | | |\ |
| 126 | | | * | 2_G |
| 127 | | |/| | |
| 128 | | | * | 2_F |
| 129 | | * | | 2_E |
| 130 | | |/ / |
| 131 | | * | 2_D |
| 132 | * | | 2_C |
| 133 | | |/ |
| 134 | |/| |
| 135 | * | 2_B |
| 136 | |/ |
| 137 | * 2_A |
| 138 | EOF |
James Coglan | d62893e | 2019-10-15 23:47:55 +0000 | [diff] [blame] | 139 | ' |
| 140 | |
| 141 | test_expect_success 'log --graph with nested right-skewed merge following left-skewed merge' ' |
Denton Liu | d784d97 | 2019-11-12 10:56:22 -0800 | [diff] [blame] | 142 | git checkout --orphan 3_p && |
| 143 | test_commit 3_A && |
| 144 | git checkout -b 3_q && |
| 145 | test_commit 3_B && |
| 146 | test_commit 3_C && |
| 147 | git checkout -b 3_r @^ && |
| 148 | test_commit 3_D && |
| 149 | git checkout 3_q && git merge --no-ff 3_r -m 3_E && |
| 150 | git checkout 3_p && git merge --no-ff 3_q -m 3_F && |
| 151 | git checkout 3_r && test_commit 3_G && |
| 152 | git checkout 3_p && git merge --no-ff 3_r -m 3_H && |
| 153 | git checkout @^^ && git merge --no-ff 3_p -m 3_J && |
| 154 | |
| 155 | check_graph <<-\EOF |
James Coglan | d62893e | 2019-10-15 23:47:55 +0000 | [diff] [blame] | 156 | * 3_J |
| 157 | |\ |
| 158 | | * 3_H |
| 159 | | |\ |
| 160 | | | * 3_G |
| 161 | | * | 3_F |
| 162 | |/| | |
James Coglan | 92beecc | 2019-10-15 23:47:58 +0000 | [diff] [blame] | 163 | | * | 3_E |
| 164 | | |\| |
James Coglan | d62893e | 2019-10-15 23:47:55 +0000 | [diff] [blame] | 165 | | | * 3_D |
| 166 | | * | 3_C |
| 167 | | |/ |
| 168 | | * 3_B |
| 169 | |/ |
| 170 | * 3_A |
| 171 | EOF |
James Coglan | d62893e | 2019-10-15 23:47:55 +0000 | [diff] [blame] | 172 | ' |
| 173 | |
| 174 | test_expect_success 'log --graph with right-skewed merge following a left-skewed one' ' |
Denton Liu | d784d97 | 2019-11-12 10:56:22 -0800 | [diff] [blame] | 175 | git checkout --orphan 4_p && |
| 176 | test_commit 4_A && |
| 177 | test_commit 4_B && |
| 178 | test_commit 4_C && |
| 179 | git checkout -b 4_q @^^ && test_commit 4_D && |
| 180 | git checkout -b 4_r 4_p^ && git merge --no-ff 4_q -m 4_E && |
| 181 | git checkout -b 4_s 4_p^^ && |
| 182 | git merge --no-ff 4_r -m 4_F && |
| 183 | git merge --no-ff 4_p -m 4_G && |
| 184 | git checkout @^^ && git merge --no-ff 4_s -m 4_H && |
| 185 | |
| 186 | check_graph --date-order <<-\EOF |
James Coglan | d62893e | 2019-10-15 23:47:55 +0000 | [diff] [blame] | 187 | * 4_H |
| 188 | |\ |
| 189 | | * 4_G |
| 190 | | |\ |
| 191 | | * | 4_F |
| 192 | |/| | |
| 193 | | * | 4_E |
| 194 | | |\ \ |
| 195 | | | * | 4_D |
| 196 | | |/ / |
| 197 | |/| | |
| 198 | | | * 4_C |
| 199 | | |/ |
| 200 | | * 4_B |
| 201 | |/ |
| 202 | * 4_A |
| 203 | EOF |
James Coglan | d62893e | 2019-10-15 23:47:55 +0000 | [diff] [blame] | 204 | ' |
| 205 | |
James Coglan | 92beecc | 2019-10-15 23:47:58 +0000 | [diff] [blame] | 206 | test_expect_success 'log --graph with octopus merge with column joining its penultimate parent' ' |
Denton Liu | d784d97 | 2019-11-12 10:56:22 -0800 | [diff] [blame] | 207 | git checkout --orphan 5_p && |
| 208 | test_commit 5_A && |
| 209 | git branch 5_q && |
| 210 | git branch 5_r && |
| 211 | test_commit 5_B && |
| 212 | git checkout 5_q && test_commit 5_C && |
| 213 | git checkout 5_r && test_commit 5_D && |
| 214 | git checkout 5_p && |
| 215 | git merge --no-ff 5_q 5_r -m 5_E && |
| 216 | git checkout 5_q && test_commit 5_F && |
| 217 | git checkout -b 5_s 5_p^ && |
| 218 | git merge --no-ff 5_p 5_q -m 5_G && |
| 219 | git checkout 5_r && |
| 220 | git merge --no-ff 5_s -m 5_H && |
| 221 | |
| 222 | check_graph <<-\EOF |
James Coglan | 92beecc | 2019-10-15 23:47:58 +0000 | [diff] [blame] | 223 | * 5_H |
| 224 | |\ |
| 225 | | *-. 5_G |
| 226 | | |\ \ |
| 227 | | | | * 5_F |
| 228 | | | * | 5_E |
| 229 | | |/|\ \ |
| 230 | | |_|/ / |
| 231 | |/| | / |
| 232 | | | |/ |
| 233 | * | | 5_D |
| 234 | | | * 5_C |
| 235 | | |/ |
| 236 | |/| |
| 237 | | * 5_B |
| 238 | |/ |
| 239 | * 5_A |
| 240 | EOF |
James Coglan | 92beecc | 2019-10-15 23:47:58 +0000 | [diff] [blame] | 241 | ' |
| 242 | |
Derrick Stolee | 0d251c3 | 2020-01-07 21:27:01 +0000 | [diff] [blame] | 243 | test_expect_success 'log --graph with multiple tips' ' |
| 244 | git checkout --orphan 6_1 && |
| 245 | test_commit 6_A && |
| 246 | git branch 6_2 && |
| 247 | git branch 6_4 && |
| 248 | test_commit 6_B && |
| 249 | git branch 6_3 && |
| 250 | test_commit 6_C && |
| 251 | git checkout 6_2 && test_commit 6_D && |
| 252 | git checkout 6_3 && test_commit 6_E && |
| 253 | git checkout -b 6_5 6_1 && |
| 254 | git merge --no-ff 6_2 -m 6_F && |
| 255 | git checkout 6_4 && test_commit 6_G && |
| 256 | git checkout 6_3 && |
| 257 | git merge --no-ff 6_4 -m 6_H && |
| 258 | git checkout 6_1 && |
| 259 | git merge --no-ff 6_2 -m 6_I && |
| 260 | |
| 261 | check_graph 6_1 6_3 6_5 <<-\EOF |
| 262 | * 6_I |
| 263 | |\ |
| 264 | | | * 6_H |
| 265 | | | |\ |
| 266 | | | | * 6_G |
| 267 | | | * | 6_E |
| 268 | | | | | * 6_F |
| 269 | | |_|_|/| |
| 270 | |/| | |/ |
| 271 | | | |/| |
| 272 | | |/| | |
| 273 | | * | | 6_D |
| 274 | | | |/ |
| 275 | | |/| |
| 276 | * | | 6_C |
| 277 | | |/ |
| 278 | |/| |
| 279 | * | 6_B |
| 280 | |/ |
| 281 | * 6_A |
| 282 | EOF |
| 283 | ' |
| 284 | |
Derrick Stolee | a1087c9 | 2020-01-07 21:27:02 +0000 | [diff] [blame] | 285 | test_expect_success 'log --graph with multiple tips and colors' ' |
| 286 | test_config log.graphColors red,green,yellow,blue,magenta,cyan && |
| 287 | cat >expect.colors <<-\EOF && |
| 288 | * 6_I |
| 289 | <RED>|<RESET><GREEN>\<RESET> |
| 290 | <RED>|<RESET> <GREEN>|<RESET> * 6_H |
| 291 | <RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET><BLUE>\<RESET> |
| 292 | <RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET> * 6_G |
| 293 | <RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET> * 6_F |
| 294 | <RED>|<RESET> <GREEN>|<RESET><RED>_<RESET><YELLOW>|<RESET><RED>_<RESET><BLUE>|<RESET><RED>/<RESET><GREEN>|<RESET> |
| 295 | <RED>|<RESET><RED>/<RESET><GREEN>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET><GREEN>/<RESET> |
| 296 | <RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET><GREEN>/<RESET><BLUE>|<RESET> |
| 297 | <RED>|<RESET> <GREEN>|<RESET><GREEN>/<RESET><YELLOW>|<RESET> <BLUE>|<RESET> |
| 298 | <RED>|<RESET> <GREEN>|<RESET> * <BLUE>|<RESET> 6_E |
| 299 | <RED>|<RESET> * <CYAN>|<RESET> <BLUE>|<RESET> 6_D |
| 300 | <RED>|<RESET> <BLUE>|<RESET> <CYAN>|<RESET><BLUE>/<RESET> |
| 301 | <RED>|<RESET> <BLUE>|<RESET><BLUE>/<RESET><CYAN>|<RESET> |
| 302 | * <BLUE>|<RESET> <CYAN>|<RESET> 6_C |
| 303 | <CYAN>|<RESET> <BLUE>|<RESET><CYAN>/<RESET> |
| 304 | <CYAN>|<RESET><CYAN>/<RESET><BLUE>|<RESET> |
| 305 | * <BLUE>|<RESET> 6_B |
| 306 | <BLUE>|<RESET><BLUE>/<RESET> |
| 307 | * 6_A |
| 308 | EOF |
Abhishek Kumar | ffe0055 | 2020-02-24 19:08:14 +0530 | [diff] [blame] | 309 | lib_test_cmp_colored_graph --date-order --pretty=tformat:%s 6_1 6_3 6_5 |
Derrick Stolee | a1087c9 | 2020-01-07 21:27:02 +0000 | [diff] [blame] | 310 | ' |
| 311 | |
Derrick Stolee | c958d3b | 2020-01-08 04:27:55 +0000 | [diff] [blame] | 312 | test_expect_success 'log --graph with multiple tips' ' |
Derrick Stolee | 8588932 | 2020-01-08 04:27:54 +0000 | [diff] [blame] | 313 | git checkout --orphan 7_1 && |
| 314 | test_commit 7_A && |
| 315 | test_commit 7_B && |
| 316 | test_commit 7_C && |
| 317 | git checkout -b 7_2 7_1~2 && |
| 318 | test_commit 7_D && |
| 319 | test_commit 7_E && |
| 320 | git checkout -b 7_3 7_1~1 && |
| 321 | test_commit 7_F && |
| 322 | test_commit 7_G && |
| 323 | git checkout -b 7_4 7_2~1 && |
| 324 | test_commit 7_H && |
| 325 | git checkout -b 7_5 7_1~2 && |
| 326 | test_commit 7_I && |
| 327 | git checkout -b 7_6 7_3~1 && |
| 328 | test_commit 7_J && |
| 329 | git checkout -b M_1 7_1 && |
| 330 | git merge --no-ff 7_2 -m 7_M1 && |
| 331 | git checkout -b M_3 7_3 && |
| 332 | git merge --no-ff 7_4 -m 7_M2 && |
| 333 | git checkout -b M_5 7_5 && |
| 334 | git merge --no-ff 7_6 -m 7_M3 && |
| 335 | git checkout -b M_7 7_1 && |
| 336 | git merge --no-ff 7_2 7_3 -m 7_M4 && |
| 337 | |
| 338 | check_graph M_1 M_3 M_5 M_7 <<-\EOF |
| 339 | * 7_M1 |
| 340 | |\ |
| 341 | | | * 7_M2 |
| 342 | | | |\ |
| 343 | | | | * 7_H |
| 344 | | | | | * 7_M3 |
| 345 | | | | | |\ |
| 346 | | | | | | * 7_J |
| 347 | | | | | * | 7_I |
| 348 | | | | | | | * 7_M4 |
| 349 | | |_|_|_|_|/|\ |
| 350 | |/| | | | |/ / |
| 351 | | | |_|_|/| / |
| 352 | | |/| | | |/ |
| 353 | | | | |_|/| |
| 354 | | | |/| | | |
| 355 | | | * | | | 7_G |
| 356 | | | | |_|/ |
| 357 | | | |/| | |
| 358 | | | * | | 7_F |
| 359 | | * | | | 7_E |
| 360 | | | |/ / |
| 361 | | |/| | |
| 362 | | * | | 7_D |
| 363 | | | |/ |
| 364 | | |/| |
| 365 | * | | 7_C |
| 366 | | |/ |
| 367 | |/| |
| 368 | * | 7_B |
| 369 | |/ |
| 370 | * 7_A |
| 371 | EOF |
| 372 | ' |
| 373 | |
James Coglan | 458152c | 2019-10-15 23:47:53 +0000 | [diff] [blame] | 374 | test_done |