1019
global stuffsaved findmergefiles maxgraphpct
1020
global maxwidth showneartags showlocalchanges
1021
global viewname viewfiles viewargs viewperm nextviewnum
1022
- global cmitmode wrapcomment datetimeformat
1022
+ global cmitmode wrapcomment datetimeformat limitdiffs
1023
global colors bgcolor fgcolor diffcolors diffcontext selectbgcolor
1024
1025
if {$stuffsaved} return
1038
puts $f [list set showneartags $showneartags]
1039
puts $f [list set showlocalchanges $showlocalchanges]
1040
puts $f [list set datetimeformat $datetimeformat]
1041
+ puts $f [list set limitdiffs $limitdiffs]
1042
puts $f [list set bgcolor $bgcolor]
1043
puts $f [list set fgcolor $fgcolor]
1044
puts $f [list set colors $colors]
5016
}
5017
}
5018
5019
+proc path_filter {filter name} {
5020
+ foreach p $filter {
5021
+ set l [string length $p]
5022
+ if {[string compare -length $l $p $name] == 0 &&
5023
+ ([string length $name] == $l || [string index $name $l] eq "/")} {
5024
+ return 1
5025
+ }
5026
+ }
5027
+ return 0
5028
+}
5029
+
5030
proc addtocflist {ids} {
5019
- global treediffs cflist
5020
- add_flist $treediffs($ids)
5031
+ global treediffs cflist viewfiles curview limitdiffs
5032
+
5033
+ if {$limitdiffs && $viewfiles($curview) ne {}} {
5034
+ set flist {}
5035
+ foreach f $treediffs($ids) {
5036
+ if {[path_filter $viewfiles($curview) $f]} {
5037
+ lappend flist $f
5038
+ }
5039
+ }
5040
+ } else {
5041
+ set flist $treediffs($ids)
5042
+ }
5043
+ add_flist $flist
5044
getblobdiffs $ids
5045
}
5046
5147
global diffopts blobdifffd diffids env
5148
global diffinhdr treediffs
5149
global diffcontext
5150
+ global limitdiffs viewfiles curview
5151
5152
set env(GIT_DIFF_OPTS) $diffopts
5129
- if {[catch {set bdf [open [diffcmd $ids "-p -C --no-commit-id -U$diffcontext"] r]} err]} {
5153
+ set cmd [diffcmd $ids "-p -C --no-commit-id -U$diffcontext"]
5154
+ if {$limitdiffs && $viewfiles($curview) ne {}} {
5155
+ set cmd [concat $cmd $viewfiles($curview)]
5156
+ }
5157
+ if {[catch {set bdf [open $cmd r]} err]} {
5158
puts "error getting diffs: $err"
5159
return
5160
}
7410
global maxwidth maxgraphpct diffopts
7411
global oldprefs prefstop showneartags showlocalchanges
7412
global bgcolor fgcolor ctext diffcolors selectbgcolor
7385
- global uifont tabstop
7413
+ global uifont tabstop limitdiffs
7414
7415
set top .gitkprefs
7416
set prefstop $top
7418
raise $top
7419
return
7420
}
7393
- foreach v {maxwidth maxgraphpct diffopts showneartags showlocalchanges} {
7421
+ foreach v {maxwidth maxgraphpct diffopts showneartags showlocalchanges \
7422
+ limitdiffs} {
7423
set oldprefs($v) [set $v]
7424
}
7425
toplevel $top
7457
label $top.tabstopl -text "tabstop" -font optionfont
7458
spinbox $top.tabstop -from 1 -to 20 -width 4 -textvariable tabstop
7459
grid x $top.tabstopl $top.tabstop -sticky w
7460
+ frame $top.ldiff
7461
+ label $top.ldiff.l -text "Limit diffs to listed paths" -font optionfont
7462
+ checkbutton $top.ldiff.b -variable limitdiffs
7463
+ pack $top.ldiff.b $top.ldiff.l -side left
7464
+ grid x $top.ldiff -sticky w
7465
7466
label $top.cdisp -text "Colors: press to choose"
7467
$top.cdisp configure -font $uifont
7548
7549
proc prefscan {} {
7550
global maxwidth maxgraphpct diffopts
7517
- global oldprefs prefstop showneartags showlocalchanges
7551
+ global oldprefs prefstop showneartags showlocalchanges limitdiffs
7552
7519
- foreach v {maxwidth maxgraphpct diffopts showneartags showlocalchanges} {
7553
+ foreach v {maxwidth maxgraphpct diffopts showneartags showlocalchanges \
7554
+ limitdiffs} {
7555
set $v $oldprefs($v)
7556
}
7557
catch {destroy $prefstop}
7561
proc prefsok {} {
7562
global maxwidth maxgraphpct
7563
global oldprefs prefstop showneartags showlocalchanges
7529
- global charspc ctext tabstop
7564
+ global charspc ctext tabstop limitdiffs
7565
7566
catch {destroy $prefstop}
7567
unset prefstop
7576
if {$maxwidth != $oldprefs(maxwidth)
7577
|| $maxgraphpct != $oldprefs(maxgraphpct)} {
7578
redisplay
7544
- } elseif {$showneartags != $oldprefs(showneartags)} {
7579
+ } elseif {$showneartags != $oldprefs(showneartags) ||
7580
+ $limitdiffs != $oldprefs(limitdiffs)} {
7581
reselectline
7582
}
7583
}
7905
set maxrefs 20
7906
set maxlinelen 200
7907
set showlocalchanges 1
7908
+set limitdiffs 1
7909
set datetimeformat "%Y-%m-%d %H:%M:%S"
7910
7911
set colors {green red blue magenta darkgrey brown orange}
7929
exit 1
7930
}
7931
7932
+set mergeonly 0
7933
set revtreeargs {}
7934
set cmdline_files {}
7935
set i 0
7937
switch -- $arg {
7938
"" { }
7939
"-d" { set datemode 1 }
7940
+ "--merge" {
7941
+ set mergeonly 1
7942
+ lappend revtreeargs $arg
7943
+ }
7944
"--" {
7945
set cmdline_files [lrange $argv [expr {$i + 1}] end]
7946
break
7981
}
7982
}
7983
7984
+if {$mergeonly} {
7985
+ # find the list of unmerged files
7986
+ set mlist {}
7987
+ set nr_unmerged 0
7988
+ if {[catch {
7989
+ set fd [open "| git ls-files -u" r]
7990
+ } err]} {
7991
+ show_error {} . "Couldn't get list of unmerged files: $err"
7992
+ exit 1
7993
+ }
7994
+ while {[gets $fd line] >= 0} {
7995
+ set i [string first "\t" $line]
7996
+ if {$i < 0} continue
7997
+ set fname [string range $line [expr {$i+1}] end]
7998
+ if {[lsearch -exact $mlist $fname] >= 0} continue
7999
+ incr nr_unmerged
8000
+ if {$cmdline_files eq {} || [path_filter $cmdline_files $fname]} {
8001
+ lappend mlist $fname
8002
+ }
8003
+ }
8004
+ catch {close $fd}
8005
+ if {$mlist eq {}} {
8006
+ if {$nr_unmerged == 0} {
8007
+ show_error {} . "No files selected: --merge specified but\
8008
+ no files are unmerged."
8009
+ } else {
8010
+ show_error {} . "No files selected: --merge specified but\
8011
+ no unmerged files are within file limit."
8012
+ }
8013
+ exit 1
8014
+ }
8015
+ set cmdline_files $mlist
8016
+}
8017
+
8018
set nullid "0000000000000000000000000000000000000000"
8019
set nullid2 "0000000000000000000000000000000000000001"
8020