@@ -131,6 +131,7 @@ proc unmerged_files {files} {
131
131
132
132
proc parseviewargs {n arglist} {
133
133
global vdatemode vmergeonly vflags vdflags vrevs vfiltered vorigargs env
134
+ global worddiff git_version
134
135
135
136
set vdatemode($n ) 0
136
137
set vmergeonly($n ) 0
@@ -168,7 +169,7 @@ proc parseviewargs {n arglist} {
168
169
lappend diffargs $arg
169
170
}
170
171
" --raw" - " --patch-with-raw" - " --patch-with-stat" -
171
- " --name-only" - " --name-status" - " --color" - " --color-words " -
172
+ " --name-only" - " --name-status" - " --color" -
172
173
" --log-size" - " --pretty=*" - " --decorate" - " --abbrev-commit" -
173
174
" --cc" - " -z" - " --header" - " --parents" - " --boundary" -
174
175
" --no-color" - " -g" - " --walk-reflogs" - " --no-walk" -
@@ -177,6 +178,18 @@ proc parseviewargs {n arglist} {
177
178
# These cause our parsing of git log's output to fail, or else
178
179
# they're options we want to set ourselves, so ignore them.
179
180
}
181
+ " --color-words*" - " --word-diff=color" {
182
+ # These trigger a word diff in the console interface,
183
+ # so help the user by enabling our own support
184
+ if {[package vcompare $git_version " 1.7.2" ] >= 0} {
185
+ set worddiff [mc " Color words" ]
186
+ }
187
+ }
188
+ " --word-diff*" {
189
+ if {[package vcompare $git_version " 1.7.2" ] >= 0} {
190
+ set worddiff [mc " Markup words" ]
191
+ }
192
+ }
180
193
" --stat=*" - " --numstat" - " --shortstat" - " --summary" -
181
194
" --check" - " --exit-code" - " --quiet" - " --topo-order" -
182
195
" --full-history" - " --dense" - " --sparse" -
@@ -1972,6 +1985,8 @@ proc makewindow {} {
1972
1985
global fprogitem fprogcoord lastprogupdate progupdatepending
1973
1986
global rprogitem rprogcoord rownumsel numcommits
1974
1987
global have_tk85 use_ttk NS
1988
+ global git_version
1989
+ global worddiff
1975
1990
1976
1991
# The "mc" arguments here are purely so that xgettext
1977
1992
# sees the following string as needing to be translated
@@ -2245,6 +2260,15 @@ proc makewindow {} {
2245
2260
${NS} ::checkbutton .bleft.mid.ignspace -text [mc " Ignore space change" ] \
2246
2261
-command changeignorespace -variable ignorespace
2247
2262
pack .bleft.mid.ignspace -side left -padx 5
2263
+
2264
+ set worddiff [mc " Line diff" ]
2265
+ if {[package vcompare $git_version " 1.7.2" ] >= 0} {
2266
+ makedroplist .bleft.mid.worddiff worddiff [mc " Line diff" ] \
2267
+ [mc " Markup words" ] [mc " Color words" ]
2268
+ trace add variable worddiff write changeworddiff
2269
+ pack .bleft.mid.worddiff -side left -padx 5
2270
+ }
2271
+
2248
2272
set ctext .bleft.bottom.ctext
2249
2273
text $ctext -background $bgcolor -foreground $fgcolor \
2250
2274
-state disabled -font textfont \
@@ -7504,11 +7528,16 @@ proc changeignorespace {} {
7504
7528
reselectline
7505
7529
}
7506
7530
7531
+ proc changeworddiff {name ix op} {
7532
+ reselectline
7533
+ }
7534
+
7507
7535
proc getblobdiffs {ids} {
7508
7536
global blobdifffd diffids env
7509
7537
global diffinhdr treediffs
7510
7538
global diffcontext
7511
7539
global ignorespace
7540
+ global worddiff
7512
7541
global limitdiffs vfilelimit curview
7513
7542
global diffencoding targetline diffnparents
7514
7543
global git_version currdiffsubmod
@@ -7525,6 +7554,9 @@ proc getblobdiffs {ids} {
7525
7554
if {$ignorespace } {
7526
7555
append cmd " -w"
7527
7556
}
7557
+ if {$worddiff ne [mc " Line diff" ]} {
7558
+ append cmd " --word-diff=porcelain"
7559
+ }
7528
7560
if {$limitdiffs && $vfilelimit($curview) ne {}} {
7529
7561
set cmd [concat $cmd -- $vfilelimit($curview) ]
7530
7562
}
@@ -7610,6 +7642,7 @@ proc getblobdiffline {bdf ids} {
7610
7642
global ctext_file_names ctext_file_lines
7611
7643
global diffinhdr treediffs mergemax diffnparents
7612
7644
global diffencoding jump_to_here targetline diffline currdiffsubmod
7645
+ global worddiff
7613
7646
7614
7647
set nr 0
7615
7648
$ctext conf -state normal
@@ -7749,15 +7782,28 @@ proc getblobdiffline {bdf ids} {
7749
7782
# parse the prefix - one ' ', '-' or '+' for each parent
7750
7783
set prefix [string range $line 0 [expr {$diffnparents - 1}]]
7751
7784
set tag [expr {$diffnparents > 1? " m" : " d" }]
7785
+ set dowords [expr {$worddiff ne [mc " Line diff" ] && $diffnparents == 1}]
7786
+ set words_pre_markup " "
7787
+ set words_post_markup " "
7752
7788
if {[string trim $prefix " -+" ] eq {}} {
7753
7789
# prefix only has " ", "-" and "+" in it: normal diff line
7754
7790
set num [string first " -" $prefix ]
7791
+ if {$dowords } {
7792
+ set line [string range $line 1 end]
7793
+ }
7755
7794
if {$num >= 0} {
7756
7795
# removed line, first parent with line is $num
7757
7796
if {$num >= $mergemax } {
7758
7797
set num " max"
7759
7798
}
7760
- $ctext insert end " $line \n " $tag$num
7799
+ if {$dowords && $worddiff eq [mc " Markup words" ]} {
7800
+ $ctext insert end " \[ -$line -\] " $tag$num
7801
+ } else {
7802
+ $ctext insert end " $line " $tag$num
7803
+ }
7804
+ if {!$dowords } {
7805
+ $ctext insert end " \n " $tag$num
7806
+ }
7761
7807
} else {
7762
7808
set tags {}
7763
7809
if {[string first " +" $prefix ] >= 0} {
@@ -7772,6 +7818,8 @@ proc getblobdiffline {bdf ids} {
7772
7818
lappend tags m$num
7773
7819
}
7774
7820
}
7821
+ set words_pre_markup " {+"
7822
+ set words_post_markup " +}"
7775
7823
}
7776
7824
if {$targetline ne {}} {
7777
7825
if {$diffline == $targetline } {
@@ -7781,8 +7829,17 @@ proc getblobdiffline {bdf ids} {
7781
7829
incr diffline
7782
7830
}
7783
7831
}
7784
- $ctext insert end " $line \n " $tags
7832
+ if {$dowords && $worddiff eq [mc " Markup words" ]} {
7833
+ $ctext insert end " $words_pre_markup$line$words_post_markup " $tags
7834
+ } else {
7835
+ $ctext insert end " $line " $tags
7836
+ }
7837
+ if {!$dowords } {
7838
+ $ctext insert end " \n " $tags
7839
+ }
7785
7840
}
7841
+ } elseif {$dowords && $prefix eq " ~" } {
7842
+ $ctext insert end " \n " {}
7786
7843
} else {
7787
7844
# "\ No newline at end of file",
7788
7845
# or something else we don't recognize
@@ -11393,6 +11450,7 @@ if {[tk windowingsystem] eq "win32"} {
11393
11450
set diffcolors {red " #00a000" blue}
11394
11451
set diffcontext 3
11395
11452
set ignorespace 0
11453
+ set worddiff " "
11396
11454
set markbgcolor " #e0e0ff"
11397
11455
11398
11456
set circlecolors {white blue gray blue blue}
0 commit comments