gitk: Show local uncommitted changes as a fake commit
If there are local changes in the repository, i.e., git-diff-index HEAD produces some output, then this optionally displays an extra row in the graph as a child of the HEAD commit (but with a red circle to indicate that it's not a real commit). There is a checkbox in the preferences window to control whether gitk does this or not. Clicking on the extra row shows the diffs between the working directory and the HEAD (using git diff-index -p). The right-click menu on the extra row allows the user to generate a patch containing the local diffs, or to display the diffs between the working directory and any commit. Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras committed
Sep 7, 2006 at 10:21 UTC
219ea3a99b9d4253815bcd71fd78eb00665acdbb
1 file changed
+284
-53
gitk
+284
-53
@@ -83,6 +83,7 @@ proc start_rev_list {view} {
83
global startmsecs
84
global commfd leftover tclencoding datemode
85
global viewargs viewfiles commitidx
86
+ global lookingforhead showlocalchanges
87
88
set startmsecs [clock clicks -milliseconds]
89
set commitidx($view) 0
@@ -103,6 +104,7 @@ proc start_rev_list {view} {
104
}
105
set commfd($view) $fd
106
set leftover($view) {}
107
+ set lookingforhead $showlocalchanges
108
fconfigure $fd -blocking 0 -translation lf
109
if {$tclencoding != {}} {
110
fconfigure $fd -encoding $tclencoding
@@ -262,7 +264,7 @@ proc chewcommits {view} {
264
set tlimit [expr {[clock clicks -milliseconds] + 50}]
265
set more [layoutmore $tlimit $allread]
266
if {$allread && !$more} {
265
- global displayorder commitidx phase
267
+ global displayorder nullid commitidx phase
268
global numcommits startmsecs
269
270
if {[info exists pending_select]} {
@@ -386,7 +388,7 @@ proc getcommit {id} {
388
389
proc readrefs {} {
390
global tagids idtags headids idheads tagcontents
389
- global otherrefids idotherrefs mainhead
391
+ global otherrefids idotherrefs mainhead mainheadid
392
393
foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
394
catch {unset $v}
@@ -433,10 +435,14 @@ proc readrefs {} {
435
}
436
close $refd
437
set mainhead {}
438
+ set mainheadid {}
439
catch {
440
set thehead [exec git symbolic-ref HEAD]
441
if {[string match "refs/heads/*" $thehead]} {
442
set mainhead [string range $thehead 11 end]
443
+ if {[info exists headids($mainhead)]} {
444
+ set mainheadid $headids($mainhead)
445
+ }
446
}
447
}
448
}
@@ -505,7 +511,7 @@ proc makewindow {} {
511
global findtype findtypemenu findloc findstring fstring geometry
512
global entries sha1entry sha1string sha1but
513
global maincursor textcursor curtextcursor
508
- global rowctxmenu mergemax wrapcomment
514
+ global rowctxmenu fakerowmenu mergemax wrapcomment
515
global highlight_files gdttype
516
global searchstring sstring
517
global bgcolor fgcolor bglist fglist diffcolors selectbgcolor
@@ -878,6 +884,17 @@ proc makewindow {} {
884
$rowctxmenu add command -label "Cherry-pick this commit" \
885
-command cherrypick
886
887
+ set fakerowmenu .fakerowmenu
888
+ menu $fakerowmenu -tearoff 0
889
+ $fakerowmenu add command -label "Diff this -> selected" \
890
+ -command {diffvssel 0}
891
+ $fakerowmenu add command -label "Diff selected -> this" \
892
+ -command {diffvssel 1}
893
+ $fakerowmenu add command -label "Make patch" -command mkpatch
894
+# $fakerowmenu add command -label "Commit" -command {mkcommit 0}
895
+# $fakerowmenu add command -label "Commit all" -command {mkcommit 1}
896
+# $fakerowmenu add command -label "Revert local changes" -command revertlocal
897
+
898
set headctxmenu .headctxmenu
899
menu $headctxmenu -tearoff 0
900
$headctxmenu add command -label "Check out this branch" \
@@ -933,7 +950,7 @@ proc click {w} {
950
proc savestuff {w} {
951
global canv canv2 canv3 ctext cflist mainfont textfont uifont tabstop
952
global stuffsaved findmergefiles maxgraphpct
936
- global maxwidth showneartags
953
+ global maxwidth showneartags showlocalchanges
954
global viewname viewfiles viewargs viewperm nextviewnum
955
global cmitmode wrapcomment
956
global colors bgcolor fgcolor diffcolors selectbgcolor
@@ -952,6 +969,7 @@ proc savestuff {w} {
969
puts $f [list set cmitmode $cmitmode]
970
puts $f [list set wrapcomment $wrapcomment]
971
puts $f [list set showneartags $showneartags]
972
+ puts $f [list set showlocalchanges $showlocalchanges]
973
puts $f [list set bgcolor $bgcolor]
974
puts $f [list set fgcolor $fgcolor]
975
puts $f [list set colors $colors]
@@ -1746,7 +1764,7 @@ proc showview {n} {
1764
global curview viewdata viewfiles
1765
global displayorder parentlist childlist rowidlist rowoffsets
1766
global colormap rowtextx commitrow nextcolor canvxmax
1749
- global numcommits rowrangelist commitlisted idrowranges
1767
+ global numcommits rowrangelist commitlisted idrowranges rowchk
1768
global selectedline currentid canv canvy0
1769
global matchinglines treediffs
1770
global pending_select phase
@@ -1832,6 +1850,7 @@ proc showview {n} {
1850
set rowlaidout [lindex $v 6]
1851
set rowoptim [lindex $v 7]
1852
set numcommits [lindex $v 8]
1853
+ catch {unset rowchk}
1854
}
1855
1856
catch {unset colormap}
@@ -1861,8 +1880,9 @@ proc showview {n} {
1880
} elseif {$selid ne {}} {
1881
set pending_select $selid
1882
} else {
1864
- if {$numcommits > 0} {
1865
- selectline 0 0
1883
+ set row [expr {[lindex $displayorder 0] eq $nullid}]
1884
+ if {$row < $numcommits} {
1885
+ selectline $row 0
1886
} else {
1887
set selectfirst 1
1888
}
@@ -2559,11 +2579,12 @@ proc layoutmore {tmax allread} {
2579
global rowlaidout rowoptim commitidx numcommits optim_delay
2580
global uparrowlen curview rowidlist idinlist
2581
2582
+ set showlast 0
2583
set showdelay $optim_delay
2584
set optdelay [expr {$uparrowlen + 1}]
2585
while {1} {
2586
if {$rowoptim - $showdelay > $numcommits} {
2566
- showstuff [expr {$rowoptim - $showdelay}]
2587
+ showstuff [expr {$rowoptim - $showdelay}] $showlast
2588
} elseif {$rowlaidout - $optdelay > $rowoptim} {
2589
set nr [expr {$rowlaidout - $optdelay - $rowoptim}]
2590
if {$nr > 100} {
@@ -2592,6 +2613,7 @@ proc layoutmore {tmax allread} {
2613
set rowlaidout $commitidx($curview)
2614
} elseif {$rowoptim == $nrows} {
2615
set showdelay 0
2616
+ set showlast 1
2617
if {$numcommits == $nrows} {
2618
return 0
2619
}
@@ -2605,9 +2627,9 @@ proc layoutmore {tmax allread} {
2627
}
2628
}
2629
2608
-proc showstuff {canshow} {
2630
+proc showstuff {canshow last} {
2631
global numcommits commitrow pending_select selectedline curview
2610
- global displayorder selectfirst
2632
+ global lookingforhead mainheadid displayorder nullid selectfirst
2633
2634
if {$numcommits == 0} {
2635
global phase
@@ -2634,10 +2656,74 @@ proc showstuff {canshow} {
2656
if {[info exists selectedline] || [info exists pending_select]} {
2657
set selectfirst 0
2658
} else {
2637
- selectline 0 1
2659
+ set l [expr {[lindex $displayorder 0] eq $nullid}]
2660
+ selectline $l 1
2661
set selectfirst 0
2662
}
2663
}
2664
+ if {$lookingforhead && [info exists commitrow($curview,$mainheadid)]
2665
+ && ($last || $commitrow($curview,$mainheadid) < $numcommits - 1)} {
2666
+ set lookingforhead 0
2667
+ dodiffindex
2668
+ }
2669
+}
2670
+
2671
+proc doshowlocalchanges {} {
2672
+ global lookingforhead curview mainheadid phase commitrow
2673
+
2674
+ if {[info exists commitrow($curview,$mainheadid)] &&
2675
+ ($phase eq {} || $commitrow($curview,$mainheadid) < $numcommits - 1)} {
2676
+ dodiffindex
2677
+ } elseif {$phase ne {}} {
2678
+ set lookingforhead 1
2679
+ }
2680
+}
2681
+
2682
+proc dohidelocalchanges {} {
2683
+ global lookingforhead localrow lserial
2684
+
2685
+ set lookingforhead 0
2686
+ if {$localrow >= 0} {
2687
+ removerow $localrow
2688
+ set localrow -1
2689
+ }
2690
+ incr lserial
2691
+}
2692
+
2693
+# spawn off a process to do git diff-index HEAD
2694
+proc dodiffindex {} {
2695
+ global localrow lserial
2696
+
2697
+ incr lserial
2698
+ set localrow -1
2699
+ set fd [open "|git diff-index HEAD" r]
2700
+ fconfigure $fd -blocking 0
2701
+ filerun $fd [list readdiffindex $fd $lserial]
2702
+}
2703
+
2704
+proc readdiffindex {fd serial} {
2705
+ global localrow commitrow mainheadid nullid curview
2706
+ global commitinfo commitdata lserial
2707
+
2708
+ if {[gets $fd line] < 0} {
2709
+ if {[eof $fd]} {
2710
+ close $fd
2711
+ return 0
2712
+ }
2713
+ return 1
2714
+ }
2715
+ # we only need to see one line and we don't really care what it says...
2716
+ close $fd
2717
+
2718
+ if {$serial == $lserial && $localrow == -1} {
2719
+ # add the line for the local diff to the graph
2720
+ set localrow $commitrow($curview,$mainheadid)
2721
+ set hl "Local uncommitted changes"
2722
+ set commitinfo($nullid) [list $hl {} {} {} {} " $hl\n"]
2723
+ set commitdata($nullid) "\n $hl\n"
2724
+ insertrow $localrow $nullid
2725
+ }
2726
+ return 0
2727
}
2728
2729
proc layoutrows {row endrow last} {
@@ -2815,7 +2901,7 @@ proc insert_pad {row col npad} {
2901
}
2902
2903
proc optimize_rows {row col endrow} {
2818
- global rowidlist rowoffsets idrowranges displayorder
2904
+ global rowidlist rowoffsets displayorder
2905
2906
for {} {$row < $endrow} {incr row} {
2907
set idlist [lindex $rowidlist $row]
@@ -3233,9 +3319,13 @@ proc drawcmittext {id row col} {
3319
global commitlisted commitinfo rowidlist parentlist
3320
global rowtextx idpos idtags idheads idotherrefs
3321
global linehtag linentag linedtag
3236
- global mainfont canvxmax boldrows boldnamerows fgcolor
3322
+ global mainfont canvxmax boldrows boldnamerows fgcolor nullid
3323
3238
- set ofill [expr {[lindex $commitlisted $row]? "blue": "white"}]
3324
+ if {$id eq $nullid} {
3325
+ set ofill red
3326
+ } else {
3327
+ set ofill [expr {[lindex $commitlisted $row]? "blue": "white"}]
3328
+ }
3329
set x [xc $row $col]
3330
set y [yc $row]
3331
set orad [expr {$linespc / 3}]
@@ -3647,10 +3737,10 @@ proc show_status {msg} {
3737
# The new commit will be displayed on row $row and the commits
3738
# on that row and below will move down one row.
3739
proc insertrow {row newcmit} {
3650
- global displayorder parentlist childlist commitlisted
3740
+ global displayorder parentlist childlist commitlisted children
3741
global commitrow curview rowidlist rowoffsets numcommits
3742
global rowrangelist rowlaidout rowoptim numcommits
3653
- global selectedline
3743
+ global selectedline rowchk commitidx
3744
3745
if {$row >= $numcommits} {
3746
puts "oops, inserting new row $row but only have $numcommits rows"
@@ -3663,12 +3753,14 @@ proc insertrow {row newcmit} {
3753
lappend kids $newcmit
3754
lset childlist $row $kids
3755
set childlist [linsert $childlist $row {}]
3756
+ set children($curview,$p) $kids
3757
set commitlisted [linsert $commitlisted $row 1]
3758
set l [llength $displayorder]
3759
for {set r $row} {$r < $l} {incr r} {
3760
set id [lindex $displayorder $r]
3761
set commitrow($curview,$id) $r
3762
}
3763
+ incr commitidx($curview)
3764
3765
set idlist [lindex $rowidlist $row]
3766
set offs [lindex $rowoffsets $row]
@@ -3704,6 +3796,8 @@ proc insertrow {row newcmit} {
3796
lset rowrangelist $rp1 $ranges
3797
}
3798
3799
+ catch {unset rowchk}
3800
+
3801
incr rowlaidout
3802
incr rowoptim
3803
incr numcommits
@@ -3714,6 +3808,67 @@ proc insertrow {row newcmit} {
3808
redisplay
3809
}
3810
3811
+# Remove a commit that was inserted with insertrow on row $row.
3812
+proc removerow {row} {
3813
+ global displayorder parentlist childlist commitlisted children
3814
+ global commitrow curview rowidlist rowoffsets numcommits
3815
+ global rowrangelist idrowranges rowlaidout rowoptim numcommits
3816
+ global linesegends selectedline rowchk commitidx
3817
+
3818
+ if {$row >= $numcommits} {
3819
+ puts "oops, removing row $row but only have $numcommits rows"
3820
+ return
3821
+ }
3822
+ set rp1 [expr {$row + 1}]
3823
+ set id [lindex $displayorder $row]
3824
+ set p [lindex $parentlist $row]
3825
+ set displayorder [lreplace $displayorder $row $row]
3826
+ set parentlist [lreplace $parentlist $row $row]
3827
+ set childlist [lreplace $childlist $row $row]
3828
+ set commitlisted [lreplace $commitlisted $row $row]
3829
+ set kids [lindex $childlist $row]
3830
+ set i [lsearch -exact $kids $id]
3831
+ if {$i >= 0} {
3832
+ set kids [lreplace $kids $i $i]
3833
+ lset childlist $row $kids
3834
+ set children($curview,$p) $kids
3835
+ }
3836
+ set l [llength $displayorder]
3837
+ for {set r $row} {$r < $l} {incr r} {
3838
+ set id [lindex $displayorder $r]
3839
+ set commitrow($curview,$id) $r
3840
+ }
3841
+ incr commitidx($curview) -1
3842
+
3843
+ set rowidlist [lreplace $rowidlist $row $row]
3844
+ set rowoffsets [lreplace $rowoffsets $rp1 $rp1]
3845
+ if {$kids ne {}} {
3846
+ set offs [lindex $rowoffsets $row]
3847
+ set offs [lreplace $offs end end]
3848
+ lset rowoffsets $row $offs
3849
+ }
3850
+
3851
+ set rowrangelist [lreplace $rowrangelist $row $row]
3852
+ if {[llength $kids] > 0} {
3853
+ set ranges [lindex $rowrangelist $row]
3854
+ if {[lindex $ranges end-1] eq $id} {
3855
+ set ranges [lreplace $ranges end-1 end]
3856
+ lset rowrangelist $row $ranges
3857
+ }
3858
+ }
3859
+
3860
+ catch {unset rowchk}
3861
+
3862
+ incr rowlaidout -1
3863
+ incr rowoptim -1
3864
+ incr numcommits -1
3865
+
3866
+ if {[info exists selectedline] && $selectedline > $row} {
3867
+ incr selectedline -1
3868
+ }
3869
+ redisplay
3870
+}
3871
+
3872
# Don't change the text pane cursor if it is currently the hand cursor,
3873
# showing that we are over a sha1 ID link.
3874
proc settextcursor {c} {
@@ -4392,13 +4547,18 @@ proc goforw {} {
4547
}
4548
4549
proc gettree {id} {
4395
- global treefilelist treeidlist diffids diffmergeid treepending
4550
+ global treefilelist treeidlist diffids diffmergeid treepending nullid
4551
4552
set diffids $id
4553
catch {unset diffmergeid}
4554
if {![info exists treefilelist($id)]} {
4555
if {![info exists treepending]} {
4401
- if {[catch {set gtf [open [concat | git ls-tree -r $id] r]}]} {
4556
+ if {$id ne $nullid} {
4557
+ set cmd [concat | git ls-tree -r $id]
4558
+ } else {
4559
+ set cmd [concat | git ls-files]
4560
+ }
4561
+ if {[catch {set gtf [open $cmd r]}]} {
4562
return
4563
}
4564
set treepending $id
@@ -4413,18 +4573,22 @@ proc gettree {id} {
4573
}
4574
4575
proc gettreeline {gtf id} {
4416
- global treefilelist treeidlist treepending cmitmode diffids
4576
+ global treefilelist treeidlist treepending cmitmode diffids nullid
4577
4578
set nl 0
4579
while {[incr nl] <= 1000 && [gets $gtf line] >= 0} {
4420
- set tl [split $line "\t"]
4421
- if {[lindex $tl 0 1] ne "blob"} continue
4422
- set sha1 [lindex $tl 0 2]
4423
- set fname [lindex $tl 1]
4424
- if {[string index $fname 0] eq "\""} {
4425
- set fname [lindex $fname 0]
4426
- }
4427
- lappend treeidlist($id) $sha1
4580
+ if {$diffids ne $nullid} {
4581
+ set tl [split $line "\t"]
4582
+ if {[lindex $tl 0 1] ne "blob"} continue
4583
+ set sha1 [lindex $tl 0 2]
4584
+ set fname [lindex $tl 1]
4585
+ if {[string index $fname 0] eq "\""} {
4586
+ set fname [lindex $fname 0]
4587
+ }
4588
+ lappend treeidlist($id) $sha1
4589
+ } else {
4590
+ set fname $line
4591
+ }
4592
lappend treefilelist($id) $fname
4593
}
4594
if {![eof $gtf]} {
@@ -4445,7 +4609,7 @@ proc gettreeline {gtf id} {
4609
}
4610
4611
proc showfile {f} {
4448
- global treefilelist treeidlist diffids
4612
+ global treefilelist treeidlist diffids nullid
4613
global ctext commentend
4614
4615
set i [lsearch -exact $treefilelist($diffids) $f]
@@ -4453,10 +4617,17 @@ proc showfile {f} {
4617
puts "oops, $f not in list for id $diffids"
4618
return
4619
}
4456
- set blob [lindex $treeidlist($diffids) $i]
4457
- if {[catch {set bf [open [concat | git cat-file blob $blob] r]} err]} {
4458
- puts "oops, error reading blob $blob: $err"
4459
- return
4620
+ if {$diffids ne $nullid} {
4621
+ set blob [lindex $treeidlist($diffids) $i]
4622
+ if {[catch {set bf [open [concat | git cat-file blob $blob] r]} err]} {
4623
+ puts "oops, error reading blob $blob: $err"
4624
+ return
4625
+ }
4626
+ } else {
4627
+ if {[catch {set bf [open $f r]} err]} {
4628
+ puts "oops, can't read $f: $err"
4629
+ return
4630
+ }
4631
}
4632
fconfigure $bf -blocking 0
4633
filerun $bf [list getblobline $bf $diffids]
@@ -4582,11 +4753,11 @@ proc getmergediffline {mdf id np} {
4753
}
4754
4755
proc startdiff {ids} {
4585
- global treediffs diffids treepending diffmergeid
4756
+ global treediffs diffids treepending diffmergeid nullid
4757
4758
set diffids $ids
4759
catch {unset diffmergeid}
4589
- if {![info exists treediffs($ids)]} {
4760
+ if {![info exists treediffs($ids)] || [lsearch -exact $ids $nullid] >= 0} {
4761
if {![info exists treepending]} {
4762
gettreediffs $ids
4763
}
@@ -4601,13 +4772,33 @@ proc addtocflist {ids} {
4772
getblobdiffs $ids
4773
}
4774
4775
+proc diffcmd {ids flags} {
4776
+ global nullid
4777
+
4778
+ set i [lsearch -exact $ids $nullid]
4779
+ if {$i >= 0} {
4780
+ set cmd [concat | git diff-index $flags]
4781
+ if {[llength $ids] > 1} {
4782
+ if {$i == 0} {
4783
+ lappend cmd -R [lindex $ids 1]
4784
+ } else {
4785
+ lappend cmd [lindex $ids 0]
4786
+ }
4787
+ } else {
4788
+ lappend cmd HEAD
4789
+ }
4790
+ } else {
4791
+ set cmd [concat | git diff-tree --no-commit-id -r $flags $ids]
4792
+ }
4793
+ return $cmd
4794
+}
4795
+
4796
proc gettreediffs {ids} {
4797
global treediff treepending
4798
+
4799
set treepending $ids
4800
set treediff {}
4608
- if {[catch \
4609
- {set gdtf [open [concat | git diff-tree --no-commit-id -r $ids] r]} \
4610
- ]} return
4801
+ if {[catch {set gdtf [open [diffcmd $ids {}] r]}]} return
4802
fconfigure $gdtf -blocking 0
4803
filerun $gdtf [list gettreediffline $gdtf $ids]
4804
}
@@ -4644,8 +4835,7 @@ proc getblobdiffs {ids} {
4835
global diffinhdr treediffs
4836
4837
set env(GIT_DIFF_OPTS) $diffopts
4647
- set cmd [concat | git diff-tree --no-commit-id -r -p -C $ids]
4648
- if {[catch {set bdf [open $cmd r]} err]} {
4838
+ if {[catch {set bdf [open [diffcmd $ids {-p -C}] r]} err]} {
4839
puts "error getting diffs: $err"
4840
return
4841
}
@@ -5207,19 +5397,25 @@ proc mstime {} {
5397
}
5398
5399
proc rowmenu {x y id} {
5210
- global rowctxmenu commitrow selectedline rowmenuid curview
5400
+ global rowctxmenu commitrow selectedline rowmenuid curview nullid
5401
+ global fakerowmenu
5402
5403
+ set rowmenuid $id
5404
if {![info exists selectedline]
5405
|| $commitrow($curview,$id) eq $selectedline} {
5406
set state disabled
5407
} else {
5408
set state normal
5409
}
5218
- $rowctxmenu entryconfigure "Diff this*" -state $state
5219
- $rowctxmenu entryconfigure "Diff selected*" -state $state
5220
- $rowctxmenu entryconfigure "Make patch" -state $state
5221
- set rowmenuid $id
5222
- tk_popup $rowctxmenu $x $y
5410
+ if {$id ne $nullid} {
5411
+ set menu $rowctxmenu
5412
+ } else {
5413
+ set menu $fakerowmenu
5414
+ }
5415
+ $menu entryconfigure "Diff this*" -state $state
5416
+ $menu entryconfigure "Diff selected*" -state $state
5417
+ $menu entryconfigure "Make patch" -state $state
5418
+ tk_popup $menu $x $y
5419
}
5420
5421
proc diffvssel {dirn} {
@@ -5330,12 +5526,20 @@ proc mkpatchrev {} {
5526
}
5527
5528
proc mkpatchgo {} {
5333
- global patchtop
5529
+ global patchtop nullid
5530
5531
set oldid [$patchtop.fromsha1 get]
5532
set newid [$patchtop.tosha1 get]
5533
set fname [$patchtop.fname get]
5338
- if {[catch {exec git diff-tree -p $oldid $newid >$fname &} err]} {
5534
+ if {$newid eq $nullid} {
5535
+ set cmd [list git diff-index -p $oldid]
5536
+ } elseif {$oldid eq $nullid} {
5537
+ set cmd [list git diff-index -p -R $newid]
5538
+ } else {
5539
+ set cmd [list git diff-tree -p $oldid $newid]
5540
+ }
5541
+ lappend cmd >$fname &
5542
+ if {[catch {eval exec $cmd} err]} {
5543
error_popup "Error creating patch: $err"
5544
}
5545
catch {destroy $patchtop}
@@ -5608,11 +5812,13 @@ proc headmenu {x y id head} {
5812
5813
proc cobranch {} {
5814
global headmenuid headmenuhead mainhead headids
5815
+ global showlocalchanges mainheadid
5816
5817
# check the tree is clean first??
5818
set oldmainhead $mainhead
5819
nowbusy checkout
5820
update
5821
+ dohidelocalchanges
5822
if {[catch {
5823
exec git checkout -q $headmenuhead
5824
} err]} {
@@ -5621,10 +5827,14 @@ proc cobranch {} {
5827
} else {
5828
notbusy checkout
5829
set mainhead $headmenuhead
5830
+ set mainheadid $headmenuid
5831
if {[info exists headids($oldmainhead)]} {
5832
redrawtags $headids($oldmainhead)
5833
}
5834
redrawtags $headmenuid
5835
+ if {$showlocalchanges} {
5836
+ dodiffindex
5837
+ }
5838
}
5839
}
5840
@@ -6594,7 +6804,7 @@ proc doquit {} {
6804
6805
proc doprefs {} {
6806
global maxwidth maxgraphpct diffopts
6597
- global oldprefs prefstop showneartags
6807
+ global oldprefs prefstop showneartags showlocalchanges
6808
global bgcolor fgcolor ctext diffcolors selectbgcolor
6809
global uifont tabstop
6810
@@ -6604,7 +6814,7 @@ proc doprefs {} {
6814
raise $top
6815
return
6816
}
6607
- foreach v {maxwidth maxgraphpct diffopts showneartags} {
6817
+ foreach v {maxwidth maxgraphpct diffopts showneartags showlocalchanges} {
6818
set oldprefs($v) [set $v]
6819
}
6820
toplevel $top
@@ -6621,6 +6831,11 @@ proc doprefs {} {
6831
-font optionfont
6832
spinbox $top.maxpct -from 1 -to 100 -width 4 -textvariable maxgraphpct
6833
grid x $top.maxpctl $top.maxpct -sticky w
6834
+ frame $top.showlocal
6835
+ label $top.showlocal.l -text "Show local changes" -font optionfont
6836
+ checkbutton $top.showlocal.b -variable showlocalchanges
6837
+ pack $top.showlocal.b $top.showlocal.l -side left
6838
+ grid x $top.showlocal -sticky w
6839
6840
label $top.ddisp -text "Diff display options"
6841
$top.ddisp configure -font $uifont
@@ -6723,9 +6938,9 @@ proc setfg {c} {
6938
6939
proc prefscan {} {
6940
global maxwidth maxgraphpct diffopts
6726
- global oldprefs prefstop showneartags
6941
+ global oldprefs prefstop showneartags showlocalchanges
6942
6728
- foreach v {maxwidth maxgraphpct diffopts showneartags} {
6943
+ foreach v {maxwidth maxgraphpct diffopts showneartags showlocalchanges} {
6944
set $v $oldprefs($v)
6945
}
6946
catch {destroy $prefstop}
@@ -6734,12 +6949,19 @@ proc prefscan {} {
6949
6950
proc prefsok {} {
6951
global maxwidth maxgraphpct
6737
- global oldprefs prefstop showneartags
6952
+ global oldprefs prefstop showneartags showlocalchanges
6953
global charspc ctext tabstop
6954
6955
catch {destroy $prefstop}
6956
unset prefstop
6957
$ctext configure -tabs "[expr {$tabstop * $charspc}]"
6958
+ if {$showlocalchanges != $oldprefs(showlocalchanges)} {
6959
+ if {$showlocalchanges} {
6960
+ doshowlocalchanges
6961
+ } else {
6962
+ dohidelocalchanges
6963
+ }
6964
+ }
6965
if {$maxwidth != $oldprefs(maxwidth)
6966
|| $maxgraphpct != $oldprefs(maxgraphpct)} {
6967
redisplay
@@ -6749,7 +6971,10 @@ proc prefsok {} {
6971
}
6972
6973
proc formatdate {d} {
6752
- return [clock format $d -format "%Y-%m-%d %H:%M:%S"]
6974
+ if {$d ne {}} {
6975
+ set d [clock format $d -format "%Y-%m-%d %H:%M:%S"]
6976
+ }
6977
+ return $d
6978
}
6979
6980
# This list of encoding names and aliases is distilled from
@@ -7059,6 +7284,7 @@ set wrapcomment "none"
7284
set showneartags 1
7285
set maxrefs 20
7286
set maxlinelen 200
7287
+set showlocalchanges 1
7288
7289
set colors {green red blue magenta darkgrey brown orange}
7290
set bgcolor white
@@ -7111,6 +7337,8 @@ if {$i >= 0} {
7337
}
7338
}
7339
7340
+set nullid "0000000000000000000000000000000000000000"
7341
+
7342
set runq {}
7343
set history {}
7344
set historyindex 0
@@ -7136,6 +7364,9 @@ set cmdlineok 0
7364
set stopped 0
7365
set stuffsaved 0
7366
set patchnum 0
7367
+set lookingforhead 0
7368
+set localrow -1
7369
+set lserial 0
7370
setcoords
7371
makewindow
7372
wm title . "[file tail $argv0]: [file tail [pwd]]"