]> git.ipfire.org Git - thirdparty/git.git/commit
merge-ll: consolidate conflict marker scanning logic
authorJunio C Hamano <gitster@pobox.com>
Fri, 31 Jul 2026 12:56:03 +0000 (05:56 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 31 Jul 2026 15:52:15 +0000 (08:52 -0700)
commite28c701fe41825013220e1b9fefe8da038070aa2
tree13a7228133a574db6f3c2a3255523aeade14738d
parent341e32111cc0bbf2542fbd8e604b5ed5187c3f98
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