Skip to content

Commit 243a7f0

Browse files
committed
Merge branch 'jc/ll-merge-internal'
"git rerere" can get confused by conflict markers deliberately left by the inner merge step, because they are indistinguishable from the real conflict markers left by the outermost merge which are what the end user and "rerere" need to look at. This was fixed by making the conflict markers left by the inner merges a bit longer. * jc/ll-merge-internal: t6036: remove pointless test that expects failure ll-merge: use a longer conflict marker for internal merge ll-merge: fix typo in comment
2 parents 5f232ec + 0f9fd5c commit 243a7f0

File tree

3 files changed

+12
-88
lines changed

3 files changed

+12
-88
lines changed

ll-merge.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ static int ll_binary_merge(const struct ll_merge_driver *drv_unused,
4747
assert(opts);
4848

4949
/*
50-
* The tentative merge result is the or common ancestor for an internal merge.
50+
* The tentative merge result is the common ancestor for an
51+
* internal merge. For the final merge, it is "ours" by
52+
* default but -Xours/-Xtheirs can tweak the choice.
5153
*/
5254
if (opts->virtual_ancestor) {
5355
stolen = orig;
@@ -383,8 +385,12 @@ int ll_merge(mmbuffer_t *result_buf,
383385
}
384386
}
385387
driver = find_ll_merge_driver(ll_driver_name);
386-
if (opts->virtual_ancestor && driver->recursive)
387-
driver = find_ll_merge_driver(driver->recursive);
388+
389+
if (opts->virtual_ancestor) {
390+
if (driver->recursive)
391+
driver = find_ll_merge_driver(driver->recursive);
392+
marker_size += 2;
393+
}
388394
return driver->fn(driver, result_buf, path, ancestor, ancestor_label,
389395
ours, our_label, theirs, their_label,
390396
opts, marker_size);

t/t6024-recursive-merge.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ test_expect_success "result contains a conflict" "test_cmp expect a1"
7676

7777
git ls-files --stage > out
7878
cat > expect << EOF
79-
100644 439cc46de773d8a83c77799b7cc9191c128bfcff 1 a1
79+
100644 ec3fe2a791706733f2d8fa7ad45d9a9672031f5e 1 a1
8080
100644 cf84443e49e1b366fac938711ddf4be2d4d1d9e9 2 a1
8181
100644 fd7923529855d0b274795ae3349c5e0438333979 3 a1
8282
EOF

t/t6036-recursive-corner-cases.sh

Lines changed: 2 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ test_expect_success 'git detects differently handled merges conflict' '
212212
-L "" \
213213
-L "Temporary merge branch 1" \
214214
merged empty merge-me &&
215-
test $(git rev-parse :1:new_a) = $(git hash-object merged)
215+
sed -e "s/^\([<=>]\)/\1\1\1/" merged >merged-internal &&
216+
test $(git rev-parse :1:new_a) = $(git hash-object merged-internal)
216217
'
217218

218219
#
@@ -298,89 +299,6 @@ test_expect_success 'git detects conflict merging criss-cross+modify/delete, rev
298299
test $(git rev-parse :3:file) = $(git rev-parse B:file)
299300
'
300301

301-
#
302-
# criss-cross + modify/modify with very contrived file contents:
303-
#
304-
# B D
305-
# o---o
306-
# / \ / \
307-
# A o X ? F
308-
# \ / \ /
309-
# o---o
310-
# C E
311-
#
312-
# Commit A: file with contents 'A\n'
313-
# Commit B: file with contents 'B\n'
314-
# Commit C: file with contents 'C\n'
315-
# Commit D: file with contents 'D\n'
316-
# Commit E: file with contents:
317-
# <<<<<<< Temporary merge branch 1
318-
# C
319-
# =======
320-
# B
321-
# >>>>>>> Temporary merge branch 2
322-
#
323-
# Now, when we merge commits D & E, does git detect the conflict?
324-
325-
test_expect_success 'setup differently handled merges of content conflict' '
326-
git clean -fdqx &&
327-
rm -rf .git &&
328-
git init &&
329-
330-
echo A >file &&
331-
git add file &&
332-
test_tick &&
333-
git commit -m A &&
334-
335-
git branch B &&
336-
git checkout -b C &&
337-
echo C >file &&
338-
git add file &&
339-
test_tick &&
340-
git commit -m C &&
341-
342-
git checkout B &&
343-
echo B >file &&
344-
git add file &&
345-
test_tick &&
346-
git commit -m B &&
347-
348-
git checkout B^0 &&
349-
test_must_fail git merge C &&
350-
echo D >file &&
351-
git add file &&
352-
test_tick &&
353-
git commit -m D &&
354-
git tag D &&
355-
356-
git checkout C^0 &&
357-
test_must_fail git merge B &&
358-
cat <<EOF >file &&
359-
<<<<<<< Temporary merge branch 1
360-
C
361-
=======
362-
B
363-
>>>>>>> Temporary merge branch 2
364-
EOF
365-
git add file &&
366-
test_tick &&
367-
git commit -m E &&
368-
git tag E
369-
'
370-
371-
test_expect_failure 'git detects conflict w/ criss-cross+contrived resolution' '
372-
git checkout D^0 &&
373-
374-
test_must_fail git merge -s recursive E^0 &&
375-
376-
test 3 -eq $(git ls-files -s | wc -l) &&
377-
test 3 -eq $(git ls-files -u | wc -l) &&
378-
test 0 -eq $(git ls-files -o | wc -l) &&
379-
380-
test $(git rev-parse :2:file) = $(git rev-parse D:file) &&
381-
test $(git rev-parse :3:file) = $(git rev-parse E:file)
382-
'
383-
384302
#
385303
# criss-cross + d/f conflict via add/add:
386304
# Commit A: Neither file 'a' nor directory 'a/' exists.

0 commit comments

Comments
 (0)