Skip to content

Commit eb8a1c4

Browse files
committed
Merge branch 'cb/maint-merge-recursive-submodule-fix' into maint
* cb/maint-merge-recursive-submodule-fix: simplify output of conflicting merge update cache for conflicting submodule entries add tests for merging with submodules
2 parents 2aa3140 + 39d8e27 commit eb8a1c4

File tree

2 files changed

+78
-12
lines changed

2 files changed

+78
-12
lines changed

merge-recursive.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,21 +1121,13 @@ static int process_entry(struct merge_options *o,
11211121
o->branch1, o->branch2);
11221122

11231123
clean_merge = mfi.clean;
1124-
if (mfi.clean)
1125-
update_file(o, 1, mfi.sha, mfi.mode, path);
1126-
else if (S_ISGITLINK(mfi.mode))
1127-
output(o, 1, "CONFLICT (submodule): Merge conflict in %s "
1128-
"- needs %s", path, sha1_to_hex(b.sha1));
1129-
else {
1124+
if (!mfi.clean) {
1125+
if (S_ISGITLINK(mfi.mode))
1126+
reason = "submodule";
11301127
output(o, 1, "CONFLICT (%s): Merge conflict in %s",
11311128
reason, path);
1132-
1133-
if (o->call_depth)
1134-
update_file(o, 0, mfi.sha, mfi.mode, path);
1135-
else
1136-
update_file_flags(o, mfi.sha, mfi.mode, path,
1137-
0 /* update_cache */, 1 /* update_working_directory */);
11381129
}
1130+
update_file(o, mfi.clean, mfi.sha, mfi.mode, path);
11391131
} else if (!o_sha && !a_sha && !b_sha) {
11401132
/*
11411133
* this entry was deleted altogether. a_mode == 0 means

t/t7405-submodule-merge.sh

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/sh
2+
3+
test_description='merging with submodules'
4+
5+
. ./test-lib.sh
6+
7+
#
8+
# history
9+
#
10+
# a --- c
11+
# / \ /
12+
# root X
13+
# \ / \
14+
# b --- d
15+
#
16+
17+
test_expect_success setup '
18+
19+
mkdir sub &&
20+
(cd sub &&
21+
git init &&
22+
echo original > file &&
23+
git add file &&
24+
test_tick &&
25+
git commit -m sub-root) &&
26+
git add sub &&
27+
test_tick &&
28+
git commit -m root &&
29+
30+
git checkout -b a master &&
31+
(cd sub &&
32+
echo A > file &&
33+
git add file &&
34+
test_tick &&
35+
git commit -m sub-a) &&
36+
git add sub &&
37+
test_tick &&
38+
git commit -m a &&
39+
40+
git checkout -b b master &&
41+
(cd sub &&
42+
echo B > file &&
43+
git add file &&
44+
test_tick &&
45+
git commit -m sub-b) &&
46+
git add sub &&
47+
test_tick &&
48+
git commit -m b
49+
50+
git checkout -b c a &&
51+
git merge -s ours b &&
52+
53+
git checkout -b d b &&
54+
git merge -s ours a
55+
'
56+
57+
test_expect_failure 'merging with modify/modify conflict' '
58+
59+
git checkout -b test1 a &&
60+
test_must_fail git merge b &&
61+
test -f .git/MERGE_MSG &&
62+
git diff
63+
64+
'
65+
66+
test_expect_success 'merging with a modify/modify conflict between merge bases' '
67+
68+
git reset --hard HEAD &&
69+
git checkout -b test2 c &&
70+
git merge d
71+
72+
'
73+
74+
test_done

0 commit comments

Comments
 (0)