1414#include "userdiff.h"
1515#include "sigchain.h"
1616#include "submodule.h"
17+ #include "ll-merge.h"
1718
1819#ifdef NO_FAST_WORKING_DIRECTORY
1920#define FAST_WORKING_DIRECTORY 0
@@ -1370,44 +1371,40 @@ static void free_diffstat_info(struct diffstat_t *diffstat)
13701371struct checkdiff_t {
13711372 const char * filename ;
13721373 int lineno ;
1374+ int conflict_marker_size ;
13731375 struct diff_options * o ;
13741376 unsigned ws_rule ;
13751377 unsigned status ;
13761378};
13771379
1378- static int is_conflict_marker (const char * line , unsigned long len )
1380+ static int is_conflict_marker (const char * line , int marker_size , unsigned long len )
13791381{
13801382 char firstchar ;
13811383 int cnt ;
13821384
1383- if (len < 8 )
1385+ if (len < marker_size + 1 )
13841386 return 0 ;
13851387 firstchar = line [0 ];
13861388 switch (firstchar ) {
1387- case '=' : case '>' : case '<' :
1389+ case '=' : case '>' : case '<' : case '|' :
13881390 break ;
13891391 default :
13901392 return 0 ;
13911393 }
1392- for (cnt = 1 ; cnt < 7 ; cnt ++ )
1394+ for (cnt = 1 ; cnt < marker_size ; cnt ++ )
13931395 if (line [cnt ] != firstchar )
13941396 return 0 ;
1395- /* line[0] thru line[6] are same as firstchar */
1396- if (firstchar == '=' ) {
1397- /* divider between ours and theirs? */
1398- if (len != 8 || line [7 ] != '\n' )
1399- return 0 ;
1400- } else if (len < 8 || !isspace (line [7 ])) {
1401- /* not divider before ours nor after theirs */
1397+ /* line[1] thru line[marker_size-1] are same as firstchar */
1398+ if (len < marker_size + 1 || !isspace (line [marker_size ]))
14021399 return 0 ;
1403- }
14041400 return 1 ;
14051401}
14061402
14071403static void checkdiff_consume (void * priv , char * line , unsigned long len )
14081404{
14091405 struct checkdiff_t * data = priv ;
14101406 int color_diff = DIFF_OPT_TST (data -> o , COLOR_DIFF );
1407+ int marker_size = data -> conflict_marker_size ;
14111408 const char * ws = diff_get_color (color_diff , DIFF_WHITESPACE );
14121409 const char * reset = diff_get_color (color_diff , DIFF_RESET );
14131410 const char * set = diff_get_color (color_diff , DIFF_FILE_NEW );
@@ -1416,7 +1413,7 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
14161413 if (line [0 ] == '+' ) {
14171414 unsigned bad ;
14181415 data -> lineno ++ ;
1419- if (is_conflict_marker (line + 1 , len - 1 )) {
1416+ if (is_conflict_marker (line + 1 , marker_size , len - 1 )) {
14201417 data -> status |= 1 ;
14211418 fprintf (data -> o -> file ,
14221419 "%s:%d: leftover conflict marker\n" ,
@@ -1860,6 +1857,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
18601857 data .lineno = 0 ;
18611858 data .o = o ;
18621859 data .ws_rule = whitespace_rule (attr_path );
1860+ data .conflict_marker_size = ll_merge_marker_size (attr_path );
18631861
18641862 if (fill_mmfile (& mf1 , one ) < 0 || fill_mmfile (& mf2 , two ) < 0 )
18651863 die ("unable to read files to diff" );
0 commit comments