| | @@ -42,10 +42,11 @@ |
| 42 | 42 | #define DIFF_INVERT (((u64)0x02)<<32) /* Invert the diff (debug) */ |
| 43 | 43 | #define DIFF_CONTEXT_EX (((u64)0x04)<<32) /* Use context even if zero */ |
| 44 | 44 | #define DIFF_NOTTOOBIG (((u64)0x08)<<32) /* Only display if not too big */ |
| 45 | 45 | #define DIFF_STRIP_EOLCR (((u64)0x10)<<32) /* Strip trailing CR */ |
| 46 | 46 | #define DIFF_SLOW_SBS (((u64)0x20)<<32) /* Better but slower side-by-side */ |
| 47 | +#define DIFF_IGNORE_PADDS (((u64)0x40)<<32) /* Ignore sections of purely adds */ |
| 47 | 48 | |
| 48 | 49 | /* |
| 49 | 50 | ** These error messages are shared in multiple locations. They are defined |
| 50 | 51 | ** here for consistency. |
| 51 | 52 | */ |
| | @@ -351,15 +352,17 @@ |
| 351 | 352 | int skip; /* Number of lines to skip */ |
| 352 | 353 | static int nChunk = 0; /* Number of diff chunks seen so far */ |
| 353 | 354 | int nContext; /* Number of lines of context */ |
| 354 | 355 | int showLn; /* Show line numbers */ |
| 355 | 356 | int html; /* Render as HTML */ |
| 357 | + int noPureAdds; /* Ignore sections that are purely additions */ |
| 356 | 358 | int showDivider = 0; /* True to show the divider between diff blocks */ |
| 357 | 359 | |
| 358 | 360 | nContext = diff_context_lines(diffFlags); |
| 359 | 361 | showLn = (diffFlags & DIFF_LINENO)!=0; |
| 360 | 362 | html = (diffFlags & DIFF_HTML)!=0; |
| 363 | + noPureAdds = (diffFlags & DIFF_IGNORE_PADDS)!=0; |
| 361 | 364 | A = p->aFrom; |
| 362 | 365 | B = p->aTo; |
| 363 | 366 | R = p->aEdit; |
| 364 | 367 | mxr = p->nEdit; |
| 365 | 368 | while( mxr>2 && R[mxr-1]==0 && R[mxr-2]==0 ){ mxr -= 3; } |
| | @@ -459,20 +462,24 @@ |
| 459 | 462 | a += m; |
| 460 | 463 | b += m; |
| 461 | 464 | |
| 462 | 465 | /* Show the differences */ |
| 463 | 466 | for(i=0; i<nr; i++){ |
| 467 | + int nDels = 0; |
| 464 | 468 | m = R[r+i*3+1]; |
| 465 | 469 | for(j=0; j<m; j++){ |
| 466 | 470 | if( showLn ) appendDiffLineno(pOut, a+j+1, 0, html); |
| 467 | 471 | appendDiffLine(pOut, '-', &A[a+j], html, pRe); |
| 472 | + nDels++; |
| 468 | 473 | } |
| 469 | 474 | a += m; |
| 470 | 475 | m = R[r+i*3+2]; |
| 471 | 476 | for(j=0; j<m; j++){ |
| 477 | + char cPrefix = '+'; |
| 478 | + if( noPureAdds && nDels==0 ) cPrefix = ' '; |
| 472 | 479 | if( showLn ) appendDiffLineno(pOut, 0, b+j+1, html); |
| 473 | | - appendDiffLine(pOut, '+', &B[b+j], html, pRe); |
| 480 | + appendDiffLine(pOut, cPrefix, &B[b+j], html, pRe); |
| 474 | 481 | } |
| 475 | 482 | b += m; |
| 476 | 483 | if( i<nr-1 ){ |
| 477 | 484 | m = R[r+i*3+3]; |
| 478 | 485 | for(j=0; j<m; j++){ |
| 479 | 486 | |