@@ -131,6 +131,7 @@ proc unmerged_files {files} {
131131
132132proc parseviewargs {n arglist} {
133133 global vdatemode vmergeonly vflags vdflags vrevs vfiltered vorigargs env
134+ global worddiff git_version
134135
135136 set vdatemode($n ) 0
136137 set vmergeonly($n ) 0
@@ -168,7 +169,7 @@ proc parseviewargs {n arglist} {
168169 lappend diffargs $arg
169170 }
170171 " --raw" - " --patch-with-raw" - " --patch-with-stat" -
171- " --name-only" - " --name-status" - " --color" - " --color-words " -
172+ " --name-only" - " --name-status" - " --color" -
172173 " --log-size" - " --pretty=*" - " --decorate" - " --abbrev-commit" -
173174 " --cc" - " -z" - " --header" - " --parents" - " --boundary" -
174175 " --no-color" - " -g" - " --walk-reflogs" - " --no-walk" -
@@ -177,6 +178,18 @@ proc parseviewargs {n arglist} {
177178 # These cause our parsing of git log's output to fail, or else
178179 # they're options we want to set ourselves, so ignore them.
179180 }
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+ }
180193 " --stat=*" - " --numstat" - " --shortstat" - " --summary" -
181194 " --check" - " --exit-code" - " --quiet" - " --topo-order" -
182195 " --full-history" - " --dense" - " --sparse" -
@@ -313,6 +326,7 @@ proc start_rev_list {view} {
313326 global viewactive viewinstances vmergeonly
314327 global mainheadid viewmainheadid viewmainheadid_orig
315328 global vcanopt vflags vrevs vorigargs
329+ global show_notes
316330
317331 set startmsecs [clock clicks -milliseconds]
318332 set commitidx($view ) 0
@@ -361,8 +375,8 @@ proc start_rev_list {view} {
361375 }
362376
363377 if {[catch {
364- set fd [open [concat | git log --no-color -z --pretty=raw --parents \
365- --boundary $args " --" $files ] r]
378+ set fd [open [concat | git log --no-color -z --pretty=raw $show_notes \
379+ --parents --boundary $args " --" $files ] r]
366380 } err]} {
367381 error_popup " [ mc " Error executing git log:" ] $err "
368382 return 0
@@ -456,6 +470,7 @@ proc updatecommits {} {
456470 global mainheadid viewmainheadid viewmainheadid_orig pending_select
457471 global isworktree
458472 global varcid vposids vnegids vflags vrevs
473+ global show_notes
459474
460475 set isworktree [expr {[exec git rev-parse --is-inside-work-tree] == " true" }]
461476 rereadrefs
@@ -508,8 +523,8 @@ proc updatecommits {} {
508523 set args $vorigargs($view)
509524 }
510525 if {[catch {
511- set fd [open [concat | git log --no-color -z --pretty=raw --parents \
512- --boundary $args " --" $vfilelimit($view) ] r]
526+ set fd [open [concat | git log --no-color -z --pretty=raw $show_notes \
527+ --parents --boundary $args " --" $vfilelimit($view) ] r]
513528 } err]} {
514529 error_popup " [ mc " Error executing git log:" ] $err "
515530 return
@@ -1970,6 +1985,8 @@ proc makewindow {} {
19701985 global fprogitem fprogcoord lastprogupdate progupdatepending
19711986 global rprogitem rprogcoord rownumsel numcommits
19721987 global have_tk85 use_ttk NS
1988+ global git_version
1989+ global worddiff
19731990
19741991 # The "mc" arguments here are purely so that xgettext
19751992 # sees the following string as needing to be translated
@@ -2243,6 +2260,15 @@ proc makewindow {} {
22432260 ${NS} ::checkbutton .bleft.mid.ignspace -text [mc " Ignore space change" ] \
22442261 -command changeignorespace -variable ignorespace
22452262 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+
22462272 set ctext .bleft.bottom.ctext
22472273 text $ctext -background $bgcolor -foreground $fgcolor \
22482274 -state disabled -font textfont \
@@ -2451,6 +2477,7 @@ proc makewindow {} {
24512477 global ctxbut
24522478 bind $cflist $ctxbut {pop_flist_menu %W %X %Y %x %y}
24532479 bind $ctext $ctxbut {pop_diff_menu %W %X %Y %x %y}
2480+ bind $ctext <Button-1> {focus %W}
24542481
24552482 set maincursor [. cget -cursor]
24562483 set textcursor [$ctext cget -cursor]
@@ -7301,6 +7328,7 @@ proc getblobline {bf id} {
73017328 [lindex [split $commentend .] 0]}]
73027329 mark_ctext_line $lnum
73037330 }
7331+ $ctext config -state disabled
73047332 return 0
73057333 }
73067334 $ctext config -state disabled
@@ -7502,11 +7530,16 @@ proc changeignorespace {} {
75027530 reselectline
75037531}
75047532
7533+ proc changeworddiff {name ix op} {
7534+ reselectline
7535+ }
7536+
75057537proc getblobdiffs {ids} {
75067538 global blobdifffd diffids env
75077539 global diffinhdr treediffs
75087540 global diffcontext
75097541 global ignorespace
7542+ global worddiff
75107543 global limitdiffs vfilelimit curview
75117544 global diffencoding targetline diffnparents
75127545 global git_version currdiffsubmod
@@ -7523,6 +7556,9 @@ proc getblobdiffs {ids} {
75237556 if {$ignorespace } {
75247557 append cmd " -w"
75257558 }
7559+ if {$worddiff ne [mc " Line diff" ]} {
7560+ append cmd " --word-diff=porcelain"
7561+ }
75267562 if {$limitdiffs && $vfilelimit($curview) ne {}} {
75277563 set cmd [concat $cmd -- $vfilelimit($curview) ]
75287564 }
@@ -7608,6 +7644,7 @@ proc getblobdiffline {bdf ids} {
76087644 global ctext_file_names ctext_file_lines
76097645 global diffinhdr treediffs mergemax diffnparents
76107646 global diffencoding jump_to_here targetline diffline currdiffsubmod
7647+ global worddiff
76117648
76127649 set nr 0
76137650 $ctext conf -state normal
@@ -7747,15 +7784,28 @@ proc getblobdiffline {bdf ids} {
77477784 # parse the prefix - one ' ', '-' or '+' for each parent
77487785 set prefix [string range $line 0 [expr {$diffnparents - 1}]]
77497786 set tag [expr {$diffnparents > 1? " m" : " d" }]
7787+ set dowords [expr {$worddiff ne [mc " Line diff" ] && $diffnparents == 1}]
7788+ set words_pre_markup " "
7789+ set words_post_markup " "
77507790 if {[string trim $prefix " -+" ] eq {}} {
77517791 # prefix only has " ", "-" and "+" in it: normal diff line
77527792 set num [string first " -" $prefix ]
7793+ if {$dowords } {
7794+ set line [string range $line 1 end]
7795+ }
77537796 if {$num >= 0} {
77547797 # removed line, first parent with line is $num
77557798 if {$num >= $mergemax } {
77567799 set num " max"
77577800 }
7758- $ctext insert end " $line \n " $tag$num
7801+ if {$dowords && $worddiff eq [mc " Markup words" ]} {
7802+ $ctext insert end " \[ -$line -\] " $tag$num
7803+ } else {
7804+ $ctext insert end " $line " $tag$num
7805+ }
7806+ if {!$dowords } {
7807+ $ctext insert end " \n " $tag$num
7808+ }
77597809 } else {
77607810 set tags {}
77617811 if {[string first " +" $prefix ] >= 0} {
@@ -7770,6 +7820,8 @@ proc getblobdiffline {bdf ids} {
77707820 lappend tags m$num
77717821 }
77727822 }
7823+ set words_pre_markup " {+"
7824+ set words_post_markup " +}"
77737825 }
77747826 if {$targetline ne {}} {
77757827 if {$diffline == $targetline } {
@@ -7779,8 +7831,17 @@ proc getblobdiffline {bdf ids} {
77797831 incr diffline
77807832 }
77817833 }
7782- $ctext insert end " $line \n " $tags
7834+ if {$dowords && $worddiff eq [mc " Markup words" ]} {
7835+ $ctext insert end " $words_pre_markup$line$words_post_markup " $tags
7836+ } else {
7837+ $ctext insert end " $line " $tags
7838+ }
7839+ if {!$dowords } {
7840+ $ctext insert end " \n " $tags
7841+ }
77837842 }
7843+ } elseif {$dowords && $prefix eq " ~" } {
7844+ $ctext insert end " \n " {}
77847845 } else {
77857846 # "\ No newline at end of file",
77867847 # or something else we don't recognize
@@ -11391,6 +11452,7 @@ if {[tk windowingsystem] eq "win32"} {
1139111452set diffcolors {red " #00a000" blue}
1139211453set diffcontext 3
1139311454set ignorespace 0
11455+ set worddiff " "
1139411456set markbgcolor " #e0e0ff"
1139511457
1139611458set circlecolors {white blue gray blue blue}
@@ -11521,6 +11583,11 @@ set NS [expr {$use_ttk ? "ttk" : ""}]
1152111583
1152211584set git_version [join [lrange [split [lindex [exec git version] end] .] 0 2] .]
1152311585
11586+ set show_notes {}
11587+ if {[package vcompare $git_version " 1.6.6.2" ] >= 0} {
11588+ set show_notes " --show-notes"
11589+ }
11590+
1152411591set runq {}
1152511592set history {}
1152611593set historyindex 0
0 commit comments