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
@@ -1370,44 +1371,40 @@ static void free_diffstat_info(struct diffstat_t *diffstat)
1370
1371
struct checkdiff_t {
1371
1372
const char * filename ;
1372
1373
int lineno ;
1374
+ int conflict_marker_size ;
1373
1375
struct diff_options * o ;
1374
1376
unsigned ws_rule ;
1375
1377
unsigned status ;
1376
1378
};
1377
1379
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 )
1379
1381
{
1380
1382
char firstchar ;
1381
1383
int cnt ;
1382
1384
1383
- if (len < 8 )
1385
+ if (len < marker_size + 1 )
1384
1386
return 0 ;
1385
1387
firstchar = line [0 ];
1386
1388
switch (firstchar ) {
1387
- case '=' : case '>' : case '<' :
1389
+ case '=' : case '>' : case '<' : case '|' :
1388
1390
break ;
1389
1391
default :
1390
1392
return 0 ;
1391
1393
}
1392
- for (cnt = 1 ; cnt < 7 ; cnt ++ )
1394
+ for (cnt = 1 ; cnt < marker_size ; cnt ++ )
1393
1395
if (line [cnt ] != firstchar )
1394
1396
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 ]))
1402
1399
return 0 ;
1403
- }
1404
1400
return 1 ;
1405
1401
}
1406
1402
1407
1403
static void checkdiff_consume (void * priv , char * line , unsigned long len )
1408
1404
{
1409
1405
struct checkdiff_t * data = priv ;
1410
1406
int color_diff = DIFF_OPT_TST (data -> o , COLOR_DIFF );
1407
+ int marker_size = data -> conflict_marker_size ;
1411
1408
const char * ws = diff_get_color (color_diff , DIFF_WHITESPACE );
1412
1409
const char * reset = diff_get_color (color_diff , DIFF_RESET );
1413
1410
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)
1416
1413
if (line [0 ] == '+' ) {
1417
1414
unsigned bad ;
1418
1415
data -> lineno ++ ;
1419
- if (is_conflict_marker (line + 1 , len - 1 )) {
1416
+ if (is_conflict_marker (line + 1 , marker_size , len - 1 )) {
1420
1417
data -> status |= 1 ;
1421
1418
fprintf (data -> o -> file ,
1422
1419
"%s:%d: leftover conflict marker\n" ,
@@ -1860,6 +1857,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
1860
1857
data .lineno = 0 ;
1861
1858
data .o = o ;
1862
1859
data .ws_rule = whitespace_rule (attr_path );
1860
+ data .conflict_marker_size = ll_merge_marker_size (attr_path );
1863
1861
1864
1862
if (fill_mmfile (& mf1 , one ) < 0 || fill_mmfile (& mf2 , two ) < 0 )
1865
1863
die ("unable to read files to diff" );
0 commit comments