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/t6433-merge-toplevel.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 / t6433-merge-toplevel.sh` 177 lines ยท 4995 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='"git merge" top-level frontend' 4 5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main 6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME 7 8 . ./test-lib.sh 9 10 t3033_reset () { 11 git checkout -B main two && 12 git branch -f left three && 13 git branch -f right four 14 } 15 16 test_expect_success setup ' 17 test_commit one && 18 git branch left && 19 git branch right && 20 test_commit two && 21 git checkout left && 22 test_commit three && 23 git checkout right && 24 test_commit four && 25 git checkout --orphan newroot && 26 test_commit five && 27 git checkout main 28 ' 29 30 # Local branches 31 32 test_expect_success 'merge an octopus into void' ' 33 t3033_reset && 34 git checkout --orphan test && 35 git rm -fr . && 36 test_must_fail git merge left right && 37 test_must_fail git rev-parse --verify HEAD && 38 git diff --quiet && 39 test_must_fail git rev-parse HEAD 40 ' 41 42 test_expect_success 'merge an octopus, fast-forward (ff)' ' 43 t3033_reset && 44 git reset --hard one && 45 git merge left right && 46 # one is ancestor of three (left) and four (right) 47 test_must_fail git rev-parse --verify HEAD^3 && 48 git rev-parse HEAD^1 HEAD^2 | sort >actual && 49 git rev-parse three four | sort >expect && 50 test_cmp expect actual 51 ' 52 53 test_expect_success 'merge octopus, non-fast-forward (ff)' ' 54 t3033_reset && 55 git reset --hard one && 56 git merge --no-ff left right && 57 # one is ancestor of three (left) and four (right) 58 test_must_fail git rev-parse --verify HEAD^4 && 59 git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual && 60 git rev-parse one three four | sort >expect && 61 test_cmp expect actual 62 ' 63 64 test_expect_success 'merge octopus, fast-forward (does not ff)' ' 65 t3033_reset && 66 git merge left right && 67 # two (main) is not an ancestor of three (left) and four (right) 68 test_must_fail git rev-parse --verify HEAD^4 && 69 git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual && 70 git rev-parse two three four | sort >expect && 71 test_cmp expect actual 72 ' 73 74 test_expect_success 'merge octopus, non-fast-forward' ' 75 t3033_reset && 76 git merge --no-ff left right && 77 test_must_fail git rev-parse --verify HEAD^4 && 78 git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual && 79 git rev-parse two three four | sort >expect && 80 test_cmp expect actual 81 ' 82 83 # The same set with FETCH_HEAD 84 85 test_expect_success 'merge FETCH_HEAD octopus into void' ' 86 t3033_reset && 87 git checkout --orphan test && 88 git rm -fr . && 89 git fetch . left right && 90 test_must_fail git merge FETCH_HEAD && 91 test_must_fail git rev-parse --verify HEAD && 92 git diff --quiet && 93 test_must_fail git rev-parse HEAD 94 ' 95 96 test_expect_success 'merge FETCH_HEAD octopus fast-forward (ff)' ' 97 t3033_reset && 98 git reset --hard one && 99 git fetch . left right && 100 git merge FETCH_HEAD && 101 # one is ancestor of three (left) and four (right) 102 test_must_fail git rev-parse --verify HEAD^3 && 103 git rev-parse HEAD^1 HEAD^2 | sort >actual && 104 git rev-parse three four | sort >expect && 105 test_cmp expect actual 106 ' 107 108 test_expect_success 'merge FETCH_HEAD octopus non-fast-forward (ff)' ' 109 t3033_reset && 110 git reset --hard one && 111 git fetch . left right && 112 git merge --no-ff FETCH_HEAD && 113 # one is ancestor of three (left) and four (right) 114 test_must_fail git rev-parse --verify HEAD^4 && 115 git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual && 116 git rev-parse one three four | sort >expect && 117 test_cmp expect actual 118 ' 119 120 test_expect_success 'merge FETCH_HEAD octopus fast-forward (does not ff)' ' 121 t3033_reset && 122 git fetch . left right && 123 git merge FETCH_HEAD && 124 # two (main) is not an ancestor of three (left) and four (right) 125 test_must_fail git rev-parse --verify HEAD^4 && 126 git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual && 127 git rev-parse two three four | sort >expect && 128 test_cmp expect actual 129 ' 130 131 test_expect_success 'merge FETCH_HEAD octopus non-fast-forward' ' 132 t3033_reset && 133 git fetch . left right && 134 git merge --no-ff FETCH_HEAD && 135 test_must_fail git rev-parse --verify HEAD^4 && 136 git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual && 137 git rev-parse two three four | sort >expect && 138 test_cmp expect actual 139 ' 140 141 # two-project merge 142 test_expect_success 'refuse two-project merge by default' ' 143 t3033_reset && 144 git reset --hard four && 145 test_must_fail git merge five 146 ' 147 148 test_expect_success 'refuse two-project merge by default, quit before --autostash happens' ' 149 t3033_reset && 150 git reset --hard four && 151 echo change >>one.t && 152 git diff >expect && 153 test_must_fail git merge --autostash five 2>err && 154 test_grep ! "stash" err && 155 git diff >actual && 156 test_cmp expect actual 157 ' 158 159 test_expect_success 'two-project merge with --allow-unrelated-histories' ' 160 t3033_reset && 161 git reset --hard four && 162 git merge --allow-unrelated-histories five && 163 git diff --exit-code five 164 ' 165 166 test_expect_success 'two-project merge with --allow-unrelated-histories with --autostash' ' 167 t3033_reset && 168 git reset --hard four && 169 echo change >>one.t && 170 git diff one.t >expect && 171 git merge --allow-unrelated-histories --autostash five 2>err && 172 test_grep "Applied autostash." err && 173 git diff one.t >actual && 174 test_cmp expect actual 175 ' 176 177 test_done