From ed34567c7bb1f3747255ca0301b84abad6d06712 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 14 Apr 2016 15:12:15 -0700 Subject: ll-merge: fix typo in comment When a944af1d (merge: teach -Xours/-Xtheirs to binary ll-merge driver, 2012-09-08) introduced FAVOR_OURS/FAVOR_THEIRS to the binary ll-merge driver, it changed what happens to the merge result for the outer merge, and updated the comment from: The tentative merge result is "ours" for the final round, or common ancestor for an internal merge. Still return "conflicted merge" status. to The tentative merge result is the or common ancestor for an internal merge. What happened is obvious. I noticed the lack of definitive article in front of "common" but failed to remove "or". Also I forgot to describe what I did for the final merge, probably because I was satisified by the description in the log message. Signed-off-by: Junio C Hamano diff --git a/ll-merge.c b/ll-merge.c index 8ea03e5..5c73274 100644 --- a/ll-merge.c +++ b/ll-merge.c @@ -46,7 +46,9 @@ static int ll_binary_merge(const struct ll_merge_driver *drv_unused, assert(opts); /* - * The tentative merge result is the or common ancestor for an internal merge. + * The tentative merge result is the common ancestor for an + * internal merge. For the final merge, it is "ours" by + * default but -Xours/-Xtheirs can tweak the choice. */ if (opts->virtual_ancestor) { stolen = orig; -- cgit v0.10.2-6-g49f6 From d694a17986a28bbc19e2a6c32404ca24572e400f Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 14 Apr 2016 15:35:09 -0700 Subject: ll-merge: use a longer conflict marker for internal merge The primary use of conflict markers is to help the user who resolves the final (outer) merge by hand to show which part came from which branch by separating the blocks of lines apart. When the conflicted parts from a "virtual ancestor" merge created by merge-recursive remains in the common ancestor part in the final result, however, the conflict markers that are the same size as the final merge become harder to see. Increase the conflict marker size slightly for these inner merges so that the markers from the final merge and cruft from internal merge can be distinguished more easily. This would help reduce the common issue that prevents "rerere" from being used on a really complex conflict. Signed-off-by: Junio C Hamano diff --git a/ll-merge.c b/ll-merge.c index 5c73274..e5ff7f6 100644 --- a/ll-merge.c +++ b/ll-merge.c @@ -376,8 +376,12 @@ int ll_merge(mmbuffer_t *result_buf, } } driver = find_ll_merge_driver(ll_driver_name); - if (opts->virtual_ancestor && driver->recursive) - driver = find_ll_merge_driver(driver->recursive); + + if (opts->virtual_ancestor) { + if (driver->recursive) + driver = find_ll_merge_driver(driver->recursive); + marker_size += 2; + } return driver->fn(driver, result_buf, path, ancestor, ancestor_label, ours, our_label, theirs, their_label, opts, marker_size); diff --git a/t/t6024-recursive-merge.sh b/t/t6024-recursive-merge.sh index 755d30c..3f59e58 100755 --- a/t/t6024-recursive-merge.sh +++ b/t/t6024-recursive-merge.sh @@ -76,7 +76,7 @@ test_expect_success "result contains a conflict" "test_cmp expect a1" git ls-files --stage > out cat > expect << EOF -100644 439cc46de773d8a83c77799b7cc9191c128bfcff 1 a1 +100644 ec3fe2a791706733f2d8fa7ad45d9a9672031f5e 1 a1 100644 cf84443e49e1b366fac938711ddf4be2d4d1d9e9 2 a1 100644 fd7923529855d0b274795ae3349c5e0438333979 3 a1 EOF diff --git a/t/t6036-recursive-corner-cases.sh b/t/t6036-recursive-corner-cases.sh index a86087b..cc1ee6a 100755 --- a/t/t6036-recursive-corner-cases.sh +++ b/t/t6036-recursive-corner-cases.sh @@ -217,7 +217,8 @@ test_expect_success 'git detects differently handled merges conflict' ' -L "" \ -L "Temporary merge branch 1" \ merged empty merge-me && - test $(git rev-parse :1:new_a) = $(git hash-object merged) + sed -e "s/^\([<=>]\)/\1\1\1/" merged >merged-internal && + test $(git rev-parse :1:new_a) = $(git hash-object merged-internal) ' # -- cgit v0.10.2-6-g49f6 From 0f9fd5c91739f62bc0c2291fe6dd6d7e1d1fa901 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 27 Apr 2016 15:05:57 -0700 Subject: t6036: remove pointless test that expects failure One test in t6036 prepares a file whose contents contain these lines: <<<<<<< Temporary merge branch 1 C ======= B >>>>>>> Temporary merge branch 2 and uses recursive merge strategy to run criss-cross merge with it. Manual merge resolution by users fundamentally depends on being able to distinguish the tracked contents from the separator lines added by "git merge" in order to allow users to tell which block of lines came from where. You can deliberately craft a file with lines that resemble conflict marker lines to make it impossible for the user (the outer merge of merge-recursive counts as a user of the result of "virtual parent" merge) to tell which part is which, and write a test to demonstrate that with such a file that "git merge" cannot fundamentally work well and has to fail. It however is pointless and waste of time and resource to run such a test that asserts the obvious. In real life, people who do need to track files with such lines that have <<<< ==== >>>> as their prefixes set the conflict-marker-size attribute to make sure they will be able to tell between the tracked lines that happen to begin with these (confusing) prefixes and the marker lines that are added by "git merge". Remove the test as pointless waste of resource. Signed-off-by: Junio C Hamano diff --git a/t/t6036-recursive-corner-cases.sh b/t/t6036-recursive-corner-cases.sh index cc1ee6a..c7b0ae6 100755 --- a/t/t6036-recursive-corner-cases.sh +++ b/t/t6036-recursive-corner-cases.sh @@ -305,89 +305,6 @@ test_expect_success 'git detects conflict merging criss-cross+modify/delete, rev ' # -# criss-cross + modify/modify with very contrived file contents: -# -# B D -# o---o -# / \ / \ -# A o X ? F -# \ / \ / -# o---o -# C E -# -# Commit A: file with contents 'A\n' -# Commit B: file with contents 'B\n' -# Commit C: file with contents 'C\n' -# Commit D: file with contents 'D\n' -# Commit E: file with contents: -# <<<<<<< Temporary merge branch 1 -# C -# ======= -# B -# >>>>>>> Temporary merge branch 2 -# -# Now, when we merge commits D & E, does git detect the conflict? - -test_expect_success 'setup differently handled merges of content conflict' ' - git clean -fdqx && - rm -rf .git && - git init && - - echo A >file && - git add file && - test_tick && - git commit -m A && - - git branch B && - git checkout -b C && - echo C >file && - git add file && - test_tick && - git commit -m C && - - git checkout B && - echo B >file && - git add file && - test_tick && - git commit -m B && - - git checkout B^0 && - test_must_fail git merge C && - echo D >file && - git add file && - test_tick && - git commit -m D && - git tag D && - - git checkout C^0 && - test_must_fail git merge B && - cat <file && -<<<<<<< Temporary merge branch 1 -C -======= -B ->>>>>>> Temporary merge branch 2 -EOF - git add file && - test_tick && - git commit -m E && - git tag E -' - -test_expect_failure 'git detects conflict w/ criss-cross+contrived resolution' ' - git checkout D^0 && - - test_must_fail git merge -s recursive E^0 && - - test 3 -eq $(git ls-files -s | wc -l) && - test 3 -eq $(git ls-files -u | wc -l) && - test 0 -eq $(git ls-files -o | wc -l) && - - test $(git rev-parse :2:file) = $(git rev-parse D:file) && - test $(git rev-parse :3:file) = $(git rev-parse E:file) -' - -# # criss-cross + d/f conflict via add/add: # Commit A: Neither file 'a' nor directory 'a/' exists. # Commit B: Introduce 'a' -- cgit v0.10.2-6-g49f6