Skip to content

Commit f065486

Browse files
author
Paul Mackerras
committed
Make the diff display less gaudy.
The old style is still available as an option (we still need a preferences window so we can set/clear it though).
1 parent f3b8b3c commit f065486

File tree

1 file changed

+32
-14
lines changed

1 file changed

+32
-14
lines changed

gitk

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ proc getcommitlines {commfd} {
6060
set stuff [read $commfd]
6161
if {$stuff == {}} {
6262
if {![eof $commfd]} return
63-
# this works around what is apparently a bug in Tcl...
63+
# set it blocking so we wait for the process to terminate
6464
fconfigure $commfd -blocking 1
6565
if {![catch {close $commfd} err]} {
6666
after idle finishcommits
@@ -273,7 +273,7 @@ proc makewindow {} {
273273
global findtype findtypemenu findloc findstring fstring geometry
274274
global entries sha1entry sha1string sha1but
275275
global maincursor textcursor
276-
global rowctxmenu
276+
global rowctxmenu gaudydiff
277277

278278
menu .bar
279279
.bar add cascade -label "File" -menu .bar.file
@@ -364,11 +364,17 @@ proc makewindow {} {
364364
pack $ctext -side left -fill both -expand 1
365365
.ctop.cdet add .ctop.cdet.left
366366

367-
$ctext tag conf filesep -font [concat $textfont bold]
368-
$ctext tag conf hunksep -back blue -fore white
369-
$ctext tag conf d0 -back "#ff8080"
370-
$ctext tag conf d1 -back green
371-
$ctext tag conf found -back yellow
367+
$ctext tag conf filesep -font [concat $textfont bold] -back "#aaaaaa"
368+
if {$gaudydiff} {
369+
$ctext tag conf hunksep -back blue -fore white
370+
$ctext tag conf d0 -back "#ff8080"
371+
$ctext tag conf d1 -back green
372+
} else {
373+
$ctext tag conf hunksep -fore blue
374+
$ctext tag conf d0 -fore red
375+
$ctext tag conf d1 -fore "#00a000"
376+
$ctext tag conf found -back yellow
377+
}
372378

373379
frame .ctop.cdet.right
374380
set cflist .ctop.cdet.right.cfiles
@@ -465,8 +471,10 @@ proc savestuff {w} {
465471
if {![winfo viewable .]} return
466472
catch {
467473
set f [open "~/.gitk-new" w]
468-
puts $f "set mainfont {$mainfont}"
469-
puts $f "set textfont {$textfont}"
474+
puts $f [list set mainfont $mainfont]
475+
puts $f [list set textfont $textfont]
476+
puts $f [list set findmergefiles $findmergefiles]
477+
puts $f [list set gaudydiff $gaudydiff]
470478
puts $f "set geometry(width) [winfo width .ctop]"
471479
puts $f "set geometry(height) [winfo height .ctop]"
472480
puts $f "set geometry(canv1) [expr [winfo width $canv]-2]"
@@ -1787,6 +1795,7 @@ proc getblobdiffline {bdf ids} {
17871795
global diffids blobdifffd ctext curdifftag curtagstart
17881796
global diffnexthead diffnextnote diffindex difffilestart
17891797
global nextupdate diffpending diffpindex diffinhdr
1798+
global gaudydiff
17901799

17911800
set n [gets $bdf line]
17921801
if {$n < 0} {
@@ -1829,18 +1838,26 @@ proc getblobdiffline {bdf ids} {
18291838
set diffinhdr 0
18301839
} elseif {[regexp {^@@ -([0-9]+),([0-9]+) \+([0-9]+),([0-9]+) @@(.*)} \
18311840
$line match f1l f1c f2l f2c rest]} {
1832-
$ctext insert end "\t" hunksep
1833-
$ctext insert end " $f1l " d0 " $f2l " d1
1834-
$ctext insert end " $rest \n" hunksep
1841+
if {$gaudydiff} {
1842+
$ctext insert end "\t" hunksep
1843+
$ctext insert end " $f1l " d0 " $f2l " d1
1844+
$ctext insert end " $rest \n" hunksep
1845+
} else {
1846+
$ctext insert end "$line\n" hunksep
1847+
}
18351848
set diffinhdr 0
18361849
} else {
18371850
set x [string range $line 0 0]
18381851
if {$x == "-" || $x == "+"} {
18391852
set tag [expr {$x == "+"}]
1840-
set line [string range $line 1 end]
1853+
if {$gaudydiff} {
1854+
set line [string range $line 1 end]
1855+
}
18411856
$ctext insert end "$line\n" d$tag
18421857
} elseif {$x == " "} {
1843-
set line [string range $line 1 end]
1858+
if {$gaudydiff} {
1859+
set line [string range $line 1 end]
1860+
}
18441861
$ctext insert end "$line\n"
18451862
} elseif {$diffinhdr || $x == "\\"} {
18461863
# e.g. "\ No newline at end of file"
@@ -2379,6 +2396,7 @@ set wrcomcmd "git-diff-tree --stdin -p --pretty"
23792396
set mainfont {Helvetica 9}
23802397
set textfont {Courier 9}
23812398
set findmergefiles 0
2399+
set gaudydiff 0
23822400

23832401
set colors {green red blue magenta darkgrey brown orange}
23842402

0 commit comments

Comments
 (0)