pack-objects: simplify --filter handling
[git/debian.git] / t / t6433-merge-toplevel.sh
blobb16031465f34b20600cadd51c2f620ec64ae0e54
1 #!/bin/sh
3 test_description='"git merge" top-level frontend'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 . ./test-lib.sh
10 t3033_reset () {
11 git checkout -B main two &&
12 git branch -f left three &&
13 git branch -f right four
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
30 # Local branches
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
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
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
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
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
83 # The same set with FETCH_HEAD
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
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
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
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
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
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
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_i18ngrep ! "stash" err &&
155 git diff >actual &&
156 test_cmp expect actual
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
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_i18ngrep "Applied autostash." err &&
173 git diff one.t >actual &&
174 test_cmp expect actual
177 test_done