Merge branch 'jt/http-redact-cookies' into maint
[git.git] / t / t3033-merge-toplevel.sh
blobd314599428129d5759e3df5e991e5a1bb90960db
1 #!/bin/sh
3 test_description='"git merge" top-level frontend'
5 . ./test-lib.sh
7 t3033_reset () {
8 git checkout -B master two &&
9 git branch -f left three &&
10 git branch -f right four
13 test_expect_success setup '
14 test_commit one &&
15 git branch left &&
16 git branch right &&
17 test_commit two &&
18 git checkout left &&
19 test_commit three &&
20 git checkout right &&
21 test_commit four &&
22 git checkout --orphan newroot &&
23 test_commit five &&
24 git checkout master
27 # Local branches
29 test_expect_success 'merge an octopus into void' '
30 t3033_reset &&
31 git checkout --orphan test &&
32 git rm -fr . &&
33 test_must_fail git merge left right &&
34 test_must_fail git rev-parse --verify HEAD &&
35 git diff --quiet &&
36 test_must_fail git rev-parse HEAD
39 test_expect_success 'merge an octopus, fast-forward (ff)' '
40 t3033_reset &&
41 git reset --hard one &&
42 git merge left right &&
43 # one is ancestor of three (left) and four (right)
44 test_must_fail git rev-parse --verify HEAD^3 &&
45 git rev-parse HEAD^1 HEAD^2 | sort >actual &&
46 git rev-parse three four | sort >expect &&
47 test_cmp expect actual
50 test_expect_success 'merge octopus, non-fast-forward (ff)' '
51 t3033_reset &&
52 git reset --hard one &&
53 git merge --no-ff left right &&
54 # one is ancestor of three (left) and four (right)
55 test_must_fail git rev-parse --verify HEAD^4 &&
56 git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual &&
57 git rev-parse one three four | sort >expect &&
58 test_cmp expect actual
61 test_expect_success 'merge octopus, fast-forward (does not ff)' '
62 t3033_reset &&
63 git merge left right &&
64 # two (master) is not an ancestor of three (left) and four (right)
65 test_must_fail git rev-parse --verify HEAD^4 &&
66 git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual &&
67 git rev-parse two three four | sort >expect &&
68 test_cmp expect actual
71 test_expect_success 'merge octopus, non-fast-forward' '
72 t3033_reset &&
73 git merge --no-ff left right &&
74 test_must_fail git rev-parse --verify HEAD^4 &&
75 git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual &&
76 git rev-parse two three four | sort >expect &&
77 test_cmp expect actual
80 # The same set with FETCH_HEAD
82 test_expect_success 'merge FETCH_HEAD octopus into void' '
83 t3033_reset &&
84 git checkout --orphan test &&
85 git rm -fr . &&
86 git fetch . left right &&
87 test_must_fail git merge FETCH_HEAD &&
88 test_must_fail git rev-parse --verify HEAD &&
89 git diff --quiet &&
90 test_must_fail git rev-parse HEAD
93 test_expect_success 'merge FETCH_HEAD octopus fast-forward (ff)' '
94 t3033_reset &&
95 git reset --hard one &&
96 git fetch . left right &&
97 git merge FETCH_HEAD &&
98 # one is ancestor of three (left) and four (right)
99 test_must_fail git rev-parse --verify HEAD^3 &&
100 git rev-parse HEAD^1 HEAD^2 | sort >actual &&
101 git rev-parse three four | sort >expect &&
102 test_cmp expect actual
105 test_expect_success 'merge FETCH_HEAD octopus non-fast-forward (ff)' '
106 t3033_reset &&
107 git reset --hard one &&
108 git fetch . left right &&
109 git merge --no-ff FETCH_HEAD &&
110 # one is ancestor of three (left) and four (right)
111 test_must_fail git rev-parse --verify HEAD^4 &&
112 git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual &&
113 git rev-parse one three four | sort >expect &&
114 test_cmp expect actual
117 test_expect_success 'merge FETCH_HEAD octopus fast-forward (does not ff)' '
118 t3033_reset &&
119 git fetch . left right &&
120 git merge FETCH_HEAD &&
121 # two (master) is not an ancestor of three (left) and four (right)
122 test_must_fail git rev-parse --verify HEAD^4 &&
123 git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual &&
124 git rev-parse two three four | sort >expect &&
125 test_cmp expect actual
128 test_expect_success 'merge FETCH_HEAD octopus non-fast-forward' '
129 t3033_reset &&
130 git fetch . left right &&
131 git merge --no-ff FETCH_HEAD &&
132 test_must_fail git rev-parse --verify HEAD^4 &&
133 git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual &&
134 git rev-parse two three four | sort >expect &&
135 test_cmp expect actual
138 # two-project merge
139 test_expect_success 'refuse two-project merge by default' '
140 t3033_reset &&
141 git reset --hard four &&
142 test_must_fail git merge five
145 test_expect_success 'two-project merge with --allow-unrelated-histories' '
146 t3033_reset &&
147 git reset --hard four &&
148 git merge --allow-unrelated-histories five &&
149 git diff --exit-code five
152 test_done