]> git.ipfire.org Git - thirdparty/git.git/commit
merge-ll: consolidate conflict marker scanning logic
authorJunio C Hamano <gitster@pobox.com>
Wed, 29 Jul 2026 17:25:22 +0000 (10:25 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 29 Jul 2026 17:26:47 +0000 (10:26 -0700)
commit045b7055cfa52c9a708366c5b92b2ca461525865
tree13a7228133a574db6f3c2a3255523aeade14738d
parentb6ae9830a9fed5ada670311f7041e3ff9f7c31f9
merge-ll: consolidate conflict marker scanning logic

The diff.c:is_conflict_marker() and rerere.c:is_cmarker() functions
implement duplicate logic for identifying conflict marker lines
(lines that begin with a run of '<', '=', '>', and '|' characters).

diff.c's original version from 049540435f (diff --check: detect
leftover conflict markers, 2008-06-26) accepts any whitespace (such
as a newline) immediately following '<<<<<<<' and '>>>>>>>', whereas
rerere.c's version from 191f241717 (rerere: prepare for customizable
conflict marker length, 2010-01-16) strictly requires a space
character (' ') after them.

Implement is_conflict_marker_line() in merge-ll.c to serve as a
replacement for both, and update diff.c and rerere.c to use the new
helper.  The unified helper intentionally adopts rerere's stricter
rule, as the conflicts generated by Git always show the "ours" and
"theirs" labels after these markers separated by a space.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c
merge-ll.c
merge-ll.h
rerere.c