Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t7603-merge-reduce-heads.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t7603-merge-reduce-heads.sh` 164 lines ยท 3780 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='git merge 4 5 Testing octopus merge when reducing parents to independent branches.' 6 7 . ./test-lib.sh 8 9 # 0 - 1 10 # \ 2 11 # \ 3 12 # \ 4 - 5 13 # 14 # So 1, 2, 3 and 5 should be kept, 4 should be avoided. 15 16 test_expect_success 'setup' ' 17 echo c0 > c0.c && 18 git add c0.c && 19 git commit -m c0 && 20 git tag c0 && 21 echo c1 > c1.c && 22 git add c1.c && 23 git commit -m c1 && 24 git tag c1 && 25 git reset --hard c0 && 26 echo c2 > c2.c && 27 git add c2.c && 28 git commit -m c2 && 29 git tag c2 && 30 git reset --hard c0 && 31 echo c3 > c3.c && 32 git add c3.c && 33 git commit -m c3 && 34 git tag c3 && 35 git reset --hard c0 && 36 echo c4 > c4.c && 37 git add c4.c && 38 git commit -m c4 && 39 git tag c4 && 40 echo c5 > c5.c && 41 git add c5.c && 42 git commit -m c5 && 43 git tag c5 44 ' 45 46 test_expect_success 'merge c1 with c2, c3, c4, c5' ' 47 git reset --hard c1 && 48 git merge c2 c3 c4 c5 && 49 test "$(git rev-parse c1)" != "$(git rev-parse HEAD)" && 50 test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" && 51 test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" && 52 test "$(git rev-parse c3)" = "$(git rev-parse HEAD^3)" && 53 test "$(git rev-parse c5)" = "$(git rev-parse HEAD^4)" && 54 git diff --exit-code && 55 test_path_is_file c0.c && 56 test_path_is_file c1.c && 57 test_path_is_file c2.c && 58 test_path_is_file c3.c && 59 test_path_is_file c4.c && 60 test_path_is_file c5.c && 61 git show --format=%s -s >actual && 62 test_grep ! c1 actual && 63 test_grep c2 actual && 64 test_grep c3 actual && 65 test_grep ! c4 actual && 66 test_grep c5 actual 67 ' 68 69 test_expect_success 'pull c2, c3, c4, c5 into c1' ' 70 git reset --hard c1 && 71 git pull --no-rebase . c2 c3 c4 c5 && 72 test "$(git rev-parse c1)" != "$(git rev-parse HEAD)" && 73 test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" && 74 test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" && 75 test "$(git rev-parse c3)" = "$(git rev-parse HEAD^3)" && 76 test "$(git rev-parse c5)" = "$(git rev-parse HEAD^4)" && 77 git diff --exit-code && 78 test_path_is_file c0.c && 79 test_path_is_file c1.c && 80 test_path_is_file c2.c && 81 test_path_is_file c3.c && 82 test_path_is_file c4.c && 83 test_path_is_file c5.c && 84 git show --format=%s -s >actual && 85 test_grep ! c1 actual && 86 test_grep c2 actual && 87 test_grep c3 actual && 88 test_grep ! c4 actual && 89 test_grep c5 actual 90 ' 91 92 test_expect_success 'setup' ' 93 for i in A B C D E 94 do 95 echo $i > $i.c && 96 git add $i.c && 97 git commit -m $i && 98 git tag $i || return 1 99 done && 100 git reset --hard A && 101 for i in F G H I 102 do 103 echo $i > $i.c && 104 git add $i.c && 105 git commit -m $i && 106 git tag $i || return 1 107 done 108 ' 109 110 test_expect_success 'merge E and I' ' 111 git reset --hard A && 112 git merge E I 113 ' 114 115 test_expect_success 'verify merge result' ' 116 test $(git rev-parse HEAD^1) = $(git rev-parse E) && 117 test $(git rev-parse HEAD^2) = $(git rev-parse I) 118 ' 119 120 test_expect_success 'add conflicts' ' 121 git reset --hard E && 122 echo foo > file.c && 123 git add file.c && 124 git commit -m E2 && 125 git tag E2 && 126 git reset --hard I && 127 echo bar >file.c && 128 git add file.c && 129 git commit -m I2 && 130 git tag I2 131 ' 132 133 test_expect_success 'merge E2 and I2, causing a conflict and resolve it' ' 134 git reset --hard A && 135 test_must_fail git merge E2 I2 && 136 echo baz > file.c && 137 git add file.c && 138 git commit -m "resolve conflict" 139 ' 140 141 test_expect_success 'verify merge result' ' 142 test $(git rev-parse HEAD^1) = $(git rev-parse E2) && 143 test $(git rev-parse HEAD^2) = $(git rev-parse I2) 144 ' 145 146 test_expect_success 'fast-forward to redundant refs' ' 147 git reset --hard c0 && 148 git merge c4 c5 149 ' 150 151 test_expect_success 'verify merge result' ' 152 test $(git rev-parse HEAD) = $(git rev-parse c5) 153 ' 154 155 test_expect_success 'merge up-to-date redundant refs' ' 156 git reset --hard c5 && 157 git merge c0 c4 158 ' 159 160 test_expect_success 'verify merge result' ' 161 test $(git rev-parse HEAD) = $(git rev-parse c5) 162 ' 163 164 test_done