@matheusbsbs / matheus-bagliano / commits / 7d056deace
Fork 0

sequencer: avoid garbled merge machinery messages due to commit labels

sequencer's get_message() exists to provide good labels on conflict hunks; see commits d68565402a ("revert: clarify label on conflict hunks", 2010-03-20) bf975d379d ("cherry-pick, revert: add a label for ancestor", 2010-03-20) 043a4492b3 ("sequencer: factor code out of revert builtin", 2012-01-11). for background on this function. These labels are of the form <commitID>... <commit summary> or parent of <commitID>... <commit summary> These labels are then passed as branch names to the merge machinery. However, these labels, as formatted, often also serve to confuse. For example, if we have a rename involved in a content merge, then it results in text such as the following: <<<<<<<< HEAD:foo.c int j; ======== int counter; >>>>>>>> b01dface... Removed unnecessary stuff:bar.c Or in various conflict messages, it can make it very difficult to read: CONFLICT (rename/delete): foo.c deleted in b01dface... Removed unnecessary stuff and renamed in HEAD. Version HEAD of foo.c left in tree. CONFLICT (file location): dir1/foo.c added in b01dface... Removed unnecessary stuff inside a directory that was renamed in HEAD, suggesting it should perhaps be moved to dir2/foo.c. Make a minor change to remove the ellipses and add parentheses around the commit summary; this makes all three examples much easier to read: <<<<<<<< HEAD:foo.c int j; ======== int counter; >>>>>>>> b01dface (Removed unnecessary stuff):bar.c CONFLICT (rename/delete): foo.c deleted in b01dface (Removed unnecessary stuff) and renamed in HEAD. Version HEAD of foo.c left in tree. CONFLICT (file location): dir1/foo.c added in b01dface (Removed unnecessary stuff) inside a directory that was renamed in HEAD, suggesting it should perhaps be moved to dir2/foo.c. Signed-off-by: Elijah Newren <newren@gmail.com> Reviewed-by: Taylor Blau <me@ttaylorr.com> Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Aug 12, 2020 at 14:40 UTC 7d056deacea488833192d517059e04916285e90f
3 files changed +12 -12
sequencer.c
+1 -1
@@ -355,7 +355,7 @@ static int get_message(struct commit *commit, struct commit_message *out)
355 subject_len = find_commit_subject(out->message, &subject);
356
357 out->subject = xmemdupz(subject, subject_len);
358 - out->label = xstrfmt("%s... %s", abbrev, out->subject);
358 + out->label = xstrfmt("%s (%s)", abbrev, out->subject);
359 out->parent_label = xstrfmt("parent of %s", out->label);
360
361 return 0;
t/t3404-rebase-interactive.sh
+1 -1
@@ -256,7 +256,7 @@ test_expect_success 'stop on conflicting pick' '
256 D
257 =======
258 G
259 - >>>>>>> $commit... G
259 + >>>>>>> $commit (G)
260 EOF
261 git tag new-branch1 &&
262 test_must_fail git rebase -i master &&
t/t3507-cherry-pick-conflict.sh
+10 -10
@@ -283,12 +283,12 @@ test_expect_success 'failed cherry-pick describes conflict in work tree' '
283 a
284 =======
285 c
286 - >>>>>>> objid picked
286 + >>>>>>> objid (picked)
287 EOF
288
289 test_must_fail git cherry-pick picked &&
290
291 - sed "s/[a-f0-9]*\.\.\./objid/" foo >actual &&
291 + sed "s/[a-f0-9]* (/objid (/" foo >actual &&
292 test_cmp expected actual
293 '
294
@@ -298,16 +298,16 @@ test_expect_success 'diff3 -m style' '
298 cat <<-EOF >expected &&
299 <<<<<<< HEAD
300 a
301 - ||||||| parent of objid picked
301 + ||||||| parent of objid (picked)
302 b
303 =======
304 c
305 - >>>>>>> objid picked
305 + >>>>>>> objid (picked)
306 EOF
307
308 test_must_fail git cherry-pick picked &&
309
310 - sed "s/[a-f0-9]*\.\.\./objid/" foo >actual &&
310 + sed "s/[a-f0-9]* (/objid (/" foo >actual &&
311 test_cmp expected actual
312 '
313
@@ -319,7 +319,7 @@ test_expect_success 'revert also handles conflicts sanely' '
319 a
320 =======
321 b
322 - >>>>>>> parent of objid picked
322 + >>>>>>> parent of objid (picked)
323 EOF
324 {
325 git checkout picked -- foo &&
@@ -345,7 +345,7 @@ test_expect_success 'revert also handles conflicts sanely' '
345 test_must_fail git update-index --refresh -q &&
346 test_must_fail git diff-index --exit-code HEAD &&
347 test_cmp expected-stages actual-stages &&
348 - sed "s/[a-f0-9]*\.\.\./objid/" foo >actual &&
348 + sed "s/[a-f0-9]* (/objid (/" foo >actual &&
349 test_cmp expected actual
350 '
351
@@ -429,16 +429,16 @@ test_expect_success 'revert conflict, diff3 -m style' '
429 cat <<-EOF >expected &&
430 <<<<<<< HEAD
431 a
432 - ||||||| objid picked
432 + ||||||| objid (picked)
433 c
434 =======
435 b
436 - >>>>>>> parent of objid picked
436 + >>>>>>> parent of objid (picked)
437 EOF
438
439 test_must_fail git revert picked &&
440
441 - sed "s/[a-f0-9]*\.\.\./objid/" foo >actual &&
441 + sed "s/[a-f0-9]* (/objid (/" foo >actual &&
442 test_cmp expected actual
443 '
444