Dave Olszewski | bf74106 | 2009-05-09 14:49:59 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='merge-recursive backend test' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | # A <- create some files |
| 8 | # / \ |
| 9 | # B C <- cause rename/delete conflicts between B and C |
| 10 | # / \ |
| 11 | # |\ /| |
| 12 | # | D E | |
| 13 | # | \ / | |
| 14 | # | X | |
| 15 | # | / \ | |
| 16 | # | / \ | |
| 17 | # |/ \| |
| 18 | # F G <- merge E into B, D into C |
| 19 | # \ / |
| 20 | # \ / |
| 21 | # \ / |
| 22 | # H <- recursive merge crashes |
| 23 | # |
| 24 | |
| 25 | # initialize |
| 26 | test_expect_success 'setup repo with criss-cross history' ' |
| 27 | mkdir data && |
| 28 | |
| 29 | # create a bunch of files |
| 30 | n=1 && |
| 31 | while test $n -le 10 |
| 32 | do |
| 33 | echo $n > data/$n && |
| 34 | n=$(($n+1)) || |
Jeff King | e6821d0 | 2015-03-25 01:29:52 -0400 | [diff] [blame] | 35 | return 1 |
Dave Olszewski | bf74106 | 2009-05-09 14:49:59 -0700 | [diff] [blame] | 36 | done && |
| 37 | |
| 38 | # check them in |
| 39 | git add data && |
| 40 | git commit -m A && |
| 41 | git branch A && |
| 42 | |
| 43 | # a file in one branch |
| 44 | git checkout -b B A && |
| 45 | git rm data/9 && |
| 46 | git add data && |
| 47 | git commit -m B && |
| 48 | |
| 49 | # with a branch off of it |
| 50 | git branch D && |
| 51 | |
| 52 | # put some commits on D |
| 53 | git checkout D && |
| 54 | echo testD > data/testD && |
| 55 | git add data && |
| 56 | git commit -m D && |
| 57 | |
| 58 | # back up to the top, create another branch and cause |
| 59 | # a rename conflict with the file we deleted earlier |
| 60 | git checkout -b C A && |
| 61 | git mv data/9 data/new-9 && |
| 62 | git add data && |
| 63 | git commit -m C && |
| 64 | |
| 65 | # with a branch off of it |
| 66 | git branch E && |
| 67 | |
| 68 | # put a commit on E |
| 69 | git checkout E && |
| 70 | echo testE > data/testE && |
| 71 | git add data && |
| 72 | git commit -m E && |
| 73 | |
| 74 | # now, merge E into B |
| 75 | git checkout B && |
| 76 | test_must_fail git merge E && |
| 77 | # force-resolve |
| 78 | git add data && |
| 79 | git commit -m F && |
| 80 | git branch F && |
| 81 | |
| 82 | # and merge D into C |
| 83 | git checkout C && |
| 84 | test_must_fail git merge D && |
| 85 | # force-resolve |
| 86 | git add data && |
| 87 | git commit -m G && |
| 88 | git branch G |
| 89 | ' |
| 90 | |
Elijah Newren | 69885ab | 2018-08-03 16:09:23 -0700 | [diff] [blame] | 91 | test_expect_success 'recursive merge between F and G does not cause segfault' ' |
Dave Olszewski | bf74106 | 2009-05-09 14:49:59 -0700 | [diff] [blame] | 92 | git merge F |
| 93 | ' |
| 94 | |
| 95 | test_done |