Fossil SCM
When using "fossil test-diff" with -y or --tk, show the names of both input files above their respective columns.
Commit
1e0e0753f6946c731befd7df9681c9d9100dfe28
Parent
8f65d49c253002d…
1 file changed
+20
-6
+20
-6
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -49,15 +49,25 @@ | ||
| 49 | 49 | if( diffFlags & DIFF_BRIEF ){ |
| 50 | 50 | /* no-op */ |
| 51 | 51 | }else if( diffFlags & DIFF_SIDEBYSIDE ){ |
| 52 | 52 | int w = diff_width(diffFlags); |
| 53 | 53 | int n1 = strlen(zLeft); |
| 54 | - int x; | |
| 55 | - if( n1>w*2 ) n1 = w*2; | |
| 56 | - x = w*2+17 - (n1+2); | |
| 57 | - z = mprintf("%.*c %.*s %.*c\n", | |
| 58 | - x/2, '=', n1, zLeft, (x+1)/2, '='); | |
| 54 | + int n2 = strlen(zRight); | |
| 55 | + int x, x2; | |
| 56 | + if( n1==n2 && fossil_strcmp(zLeft,zRight)==0 ){ | |
| 57 | + if( n1>w*2 ) n1 = w*2; | |
| 58 | + x = w*2+17 - (n1+2); | |
| 59 | + z = mprintf("%.*c %.*s %.*c\n", | |
| 60 | + x/2, '=', n1, zLeft, (x+1)/2, '='); | |
| 61 | + }else{ | |
| 62 | + if( w<20 ) w = 20; | |
| 63 | + if( n1>w-10 ) n1 = w - 10; | |
| 64 | + if( n2>w-10 ) n2 = w - 10; | |
| 65 | + z = mprintf("%.*c %.*s %.*c versus %.*c %.*s %.*c\n", | |
| 66 | + (w-n1+10)/2, '=', n1, zLeft, (w-n1+1)/2, '=', | |
| 67 | + (w-n2)/2, '=', n2, zRight, (w-n2+1)/2, '='); | |
| 68 | + } | |
| 59 | 69 | }else{ |
| 60 | 70 | z = mprintf("--- %s\n+++ %s\n", zLeft, zRight); |
| 61 | 71 | } |
| 62 | 72 | fossil_print("%s", z); |
| 63 | 73 | fossil_free(z); |
| @@ -664,11 +674,14 @@ | ||
| 664 | 674 | @ set N [llength $difftxt] |
| 665 | 675 | @ set ii 0 |
| 666 | 676 | @ set nDiffs 0 |
| 667 | 677 | @ array set widths {txt 0 ln 0 mkr 0} |
| 668 | 678 | @ while {[set line [getLine $difftxt $N ii]] != -1} { |
| 669 | -@ if {![regexp {^=+\s+(.*?)\s+=+$} $line all fn]} { | |
| 679 | +@ set fn2 {} | |
| 680 | +@ if {![regexp {^=+ (.*?) =+ versus =+ (.*?) =+$} $line all fn fn2] | |
| 681 | +@ && ![regexp {^=+ (.*?) =+$} $line all fn] | |
| 682 | +@ } { | |
| 670 | 683 | @ continue |
| 671 | 684 | @ } |
| 672 | 685 | @ if {[string compare -length 6 [getLine $difftxt $N ii] "<table"]} { |
| 673 | 686 | @ continue |
| 674 | 687 | @ } |
| @@ -682,10 +695,11 @@ | ||
| 682 | 695 | @ if {$nDiffs > 1} { |
| 683 | 696 | @ $c insert end \n - |
| 684 | 697 | @ } |
| 685 | 698 | @ if {[colType $c] eq "txt"} { |
| 686 | 699 | @ $c insert end $fn\n fn |
| 700 | +@ if {$fn2!=""} {set fn $fn2} | |
| 687 | 701 | @ } else { |
| 688 | 702 | @ $c insert end \n fn |
| 689 | 703 | @ } |
| 690 | 704 | @ $c insert end \n - |
| 691 | 705 | @ |
| 692 | 706 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -49,15 +49,25 @@ | |
| 49 | if( diffFlags & DIFF_BRIEF ){ |
| 50 | /* no-op */ |
| 51 | }else if( diffFlags & DIFF_SIDEBYSIDE ){ |
| 52 | int w = diff_width(diffFlags); |
| 53 | int n1 = strlen(zLeft); |
| 54 | int x; |
| 55 | if( n1>w*2 ) n1 = w*2; |
| 56 | x = w*2+17 - (n1+2); |
| 57 | z = mprintf("%.*c %.*s %.*c\n", |
| 58 | x/2, '=', n1, zLeft, (x+1)/2, '='); |
| 59 | }else{ |
| 60 | z = mprintf("--- %s\n+++ %s\n", zLeft, zRight); |
| 61 | } |
| 62 | fossil_print("%s", z); |
| 63 | fossil_free(z); |
| @@ -664,11 +674,14 @@ | |
| 664 | @ set N [llength $difftxt] |
| 665 | @ set ii 0 |
| 666 | @ set nDiffs 0 |
| 667 | @ array set widths {txt 0 ln 0 mkr 0} |
| 668 | @ while {[set line [getLine $difftxt $N ii]] != -1} { |
| 669 | @ if {![regexp {^=+\s+(.*?)\s+=+$} $line all fn]} { |
| 670 | @ continue |
| 671 | @ } |
| 672 | @ if {[string compare -length 6 [getLine $difftxt $N ii] "<table"]} { |
| 673 | @ continue |
| 674 | @ } |
| @@ -682,10 +695,11 @@ | |
| 682 | @ if {$nDiffs > 1} { |
| 683 | @ $c insert end \n - |
| 684 | @ } |
| 685 | @ if {[colType $c] eq "txt"} { |
| 686 | @ $c insert end $fn\n fn |
| 687 | @ } else { |
| 688 | @ $c insert end \n fn |
| 689 | @ } |
| 690 | @ $c insert end \n - |
| 691 | @ |
| 692 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -49,15 +49,25 @@ | |
| 49 | if( diffFlags & DIFF_BRIEF ){ |
| 50 | /* no-op */ |
| 51 | }else if( diffFlags & DIFF_SIDEBYSIDE ){ |
| 52 | int w = diff_width(diffFlags); |
| 53 | int n1 = strlen(zLeft); |
| 54 | int n2 = strlen(zRight); |
| 55 | int x, x2; |
| 56 | if( n1==n2 && fossil_strcmp(zLeft,zRight)==0 ){ |
| 57 | if( n1>w*2 ) n1 = w*2; |
| 58 | x = w*2+17 - (n1+2); |
| 59 | z = mprintf("%.*c %.*s %.*c\n", |
| 60 | x/2, '=', n1, zLeft, (x+1)/2, '='); |
| 61 | }else{ |
| 62 | if( w<20 ) w = 20; |
| 63 | if( n1>w-10 ) n1 = w - 10; |
| 64 | if( n2>w-10 ) n2 = w - 10; |
| 65 | z = mprintf("%.*c %.*s %.*c versus %.*c %.*s %.*c\n", |
| 66 | (w-n1+10)/2, '=', n1, zLeft, (w-n1+1)/2, '=', |
| 67 | (w-n2)/2, '=', n2, zRight, (w-n2+1)/2, '='); |
| 68 | } |
| 69 | }else{ |
| 70 | z = mprintf("--- %s\n+++ %s\n", zLeft, zRight); |
| 71 | } |
| 72 | fossil_print("%s", z); |
| 73 | fossil_free(z); |
| @@ -664,11 +674,14 @@ | |
| 674 | @ set N [llength $difftxt] |
| 675 | @ set ii 0 |
| 676 | @ set nDiffs 0 |
| 677 | @ array set widths {txt 0 ln 0 mkr 0} |
| 678 | @ while {[set line [getLine $difftxt $N ii]] != -1} { |
| 679 | @ set fn2 {} |
| 680 | @ if {![regexp {^=+ (.*?) =+ versus =+ (.*?) =+$} $line all fn fn2] |
| 681 | @ && ![regexp {^=+ (.*?) =+$} $line all fn] |
| 682 | @ } { |
| 683 | @ continue |
| 684 | @ } |
| 685 | @ if {[string compare -length 6 [getLine $difftxt $N ii] "<table"]} { |
| 686 | @ continue |
| 687 | @ } |
| @@ -682,10 +695,11 @@ | |
| 695 | @ if {$nDiffs > 1} { |
| 696 | @ $c insert end \n - |
| 697 | @ } |
| 698 | @ if {[colType $c] eq "txt"} { |
| 699 | @ $c insert end $fn\n fn |
| 700 | @ if {$fn2!=""} {set fn $fn2} |
| 701 | @ } else { |
| 702 | @ $c insert end \n fn |
| 703 | @ } |
| 704 | @ $c insert end \n - |
| 705 | @ |
| 706 |