14
14
#include "userdiff.h"
15
15
#include "sigchain.h"
16
16
#include "submodule.h"
17
+ #include "ll-merge.h"
17
18
18
19
#ifdef NO_FAST_WORKING_DIRECTORY
19
20
#define FAST_WORKING_DIRECTORY 0
@@ -1364,44 +1365,40 @@ static void free_diffstat_info(struct diffstat_t *diffstat)
1364
1365
struct checkdiff_t {
1365
1366
const char * filename ;
1366
1367
int lineno ;
1368
+ int conflict_marker_size ;
1367
1369
struct diff_options * o ;
1368
1370
unsigned ws_rule ;
1369
1371
unsigned status ;
1370
1372
};
1371
1373
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 )
1373
1375
{
1374
1376
char firstchar ;
1375
1377
int cnt ;
1376
1378
1377
- if (len < 8 )
1379
+ if (len < marker_size + 1 )
1378
1380
return 0 ;
1379
1381
firstchar = line [0 ];
1380
1382
switch (firstchar ) {
1381
- case '=' : case '>' : case '<' :
1383
+ case '=' : case '>' : case '<' : case '|' :
1382
1384
break ;
1383
1385
default :
1384
1386
return 0 ;
1385
1387
}
1386
- for (cnt = 1 ; cnt < 7 ; cnt ++ )
1388
+ for (cnt = 1 ; cnt < marker_size ; cnt ++ )
1387
1389
if (line [cnt ] != firstchar )
1388
1390
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 ]))
1396
1393
return 0 ;
1397
- }
1398
1394
return 1 ;
1399
1395
}
1400
1396
1401
1397
static void checkdiff_consume (void * priv , char * line , unsigned long len )
1402
1398
{
1403
1399
struct checkdiff_t * data = priv ;
1404
1400
int color_diff = DIFF_OPT_TST (data -> o , COLOR_DIFF );
1401
+ int marker_size = data -> conflict_marker_size ;
1405
1402
const char * ws = diff_get_color (color_diff , DIFF_WHITESPACE );
1406
1403
const char * reset = diff_get_color (color_diff , DIFF_RESET );
1407
1404
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)
1410
1407
if (line [0 ] == '+' ) {
1411
1408
unsigned bad ;
1412
1409
data -> lineno ++ ;
1413
- if (is_conflict_marker (line + 1 , len - 1 )) {
1410
+ if (is_conflict_marker (line + 1 , marker_size , len - 1 )) {
1414
1411
data -> status |= 1 ;
1415
1412
fprintf (data -> o -> file ,
1416
1413
"%s:%d: leftover conflict marker\n" ,
@@ -1841,6 +1838,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
1841
1838
data .lineno = 0 ;
1842
1839
data .o = o ;
1843
1840
data .ws_rule = whitespace_rule (attr_path );
1841
+ data .conflict_marker_size = ll_merge_marker_size (attr_path );
1844
1842
1845
1843
if (fill_mmfile (& mf1 , one ) < 0 || fill_mmfile (& mf2 , two ) < 0 )
1846
1844
die ("unable to read files to diff" );
0 commit comments