ci: skip GitHub workflow runs for already-tested commits/trees
[git.git] / t / t6433-merge-toplevel.sh
blobe29c284b9b9b06a333c9e6d8b5240821403275b3
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 'refuse two-project merge by default, quit before --autostash happens' '
146 t3033_reset &&
147 git reset --hard four &&
148 echo change >>one.t &&
149 git diff >expect &&
150 test_must_fail git merge --autostash five 2>err &&
151 test_i18ngrep ! "stash" err &&
152 git diff >actual &&
153 test_cmp expect actual
156 test_expect_success 'two-project merge with --allow-unrelated-histories' '
157 t3033_reset &&
158 git reset --hard four &&
159 git merge --allow-unrelated-histories five &&
160 git diff --exit-code five
163 test_expect_success 'two-project merge with --allow-unrelated-histories with --autostash' '
164 t3033_reset &&
165 git reset --hard four &&
166 echo change >>one.t &&
167 git diff one.t >expect &&
168 git merge --allow-unrelated-histories --autostash five 2>err &&
169 test_i18ngrep "Applied autostash." err &&
170 git diff one.t >actual &&
171 test_cmp expect actual
174 test_done