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
@@ -1364,44 +1365,40 @@ static void free_diffstat_info(struct diffstat_t *diffstat)
13641365struct checkdiff_t {
13651366 const char * filename ;
13661367 int lineno ;
1368+ int conflict_marker_size ;
13671369 struct diff_options * o ;
13681370 unsigned ws_rule ;
13691371 unsigned status ;
13701372};
13711373
1372- static int is_conflict_marker (const char * line , unsigned long len )
1374+ static int is_conflict_marker (const char * line , int marker_size , unsigned long len )
13731375{
13741376 char firstchar ;
13751377 int cnt ;
13761378
1377- if (len < 8 )
1379+ if (len < marker_size + 1 )
13781380 return 0 ;
13791381 firstchar = line [0 ];
13801382 switch (firstchar ) {
1381- case '=' : case '>' : case '<' :
1383+ case '=' : case '>' : case '<' : case '|' :
13821384 break ;
13831385 default :
13841386 return 0 ;
13851387 }
1386- for (cnt = 1 ; cnt < 7 ; cnt ++ )
1388+ for (cnt = 1 ; cnt < marker_size ; cnt ++ )
13871389 if (line [cnt ] != firstchar )
13881390 return 0 ;
1389- /* line[0] thru line[6] are same as firstchar */
1390- if (firstchar == '=' ) {
1391- /* divider between ours and theirs? */
1392- if (len != 8 || line [7 ] != '\n' )
1393- return 0 ;
1394- } else if (len < 8 || !isspace (line [7 ])) {
1395- /* not divider before ours nor after theirs */
1391+ /* line[1] thru line[marker_size-1] are same as firstchar */
1392+ if (len < marker_size + 1 || !isspace (line [marker_size ]))
13961393 return 0 ;
1397- }
13981394 return 1 ;
13991395}
14001396
14011397static void checkdiff_consume (void * priv , char * line , unsigned long len )
14021398{
14031399 struct checkdiff_t * data = priv ;
14041400 int color_diff = DIFF_OPT_TST (data -> o , COLOR_DIFF );
1401+ int marker_size = data -> conflict_marker_size ;
14051402 const char * ws = diff_get_color (color_diff , DIFF_WHITESPACE );
14061403 const char * reset = diff_get_color (color_diff , DIFF_RESET );
14071404 const char * set = diff_get_color (color_diff , DIFF_FILE_NEW );
@@ -1410,7 +1407,7 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
14101407 if (line [0 ] == '+' ) {
14111408 unsigned bad ;
14121409 data -> lineno ++ ;
1413- if (is_conflict_marker (line + 1 , len - 1 )) {
1410+ if (is_conflict_marker (line + 1 , marker_size , len - 1 )) {
14141411 data -> status |= 1 ;
14151412 fprintf (data -> o -> file ,
14161413 "%s:%d: leftover conflict marker\n" ,
@@ -1841,6 +1838,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
18411838 data .lineno = 0 ;
18421839 data .o = o ;
18431840 data .ws_rule = whitespace_rule (attr_path );
1841+ data .conflict_marker_size = ll_merge_marker_size (attr_path );
18441842
18451843 if (fill_mmfile (& mf1 , one ) < 0 || fill_mmfile (& mf2 , two ) < 0 )
18461844 die ("unable to read files to diff" );
0 commit comments