@matheusbsbs / matheus-bagliano / commits / 74a40c7110
Fork 0

gitk: Fix a couple more bugs in the path limiting

First, paths ending in a slash were not matching anything. This fixes path_filter to handle paths ending in a slash (such entries have to match a directory, and can't match a file, e.g., foo/bar/ can't match a plain file called foo/bar). Secondly, clicking in the file list pane (bottom right) was broken because $treediffs($ids) contained all the files modified by the commit, not just those within the file list. This fixes that too. Signed-off-by: Paul Mackerras <paulus@samba.org>

Paul Mackerras committed Oct 24, 2007 at 10:16 UTC 74a40c71102ea925b174da15c74afb15b6b82537
1 file changed +29 -18
gitk
+29 -18
@@ -5023,28 +5023,25 @@ proc startdiff {ids} {
5023 proc path_filter {filter name} {
5024 foreach p $filter {
5025 set l [string length $p]
5026 - if {[string compare -length $l $p $name] == 0 &&
5027 - ([string length $name] == $l || [string index $name $l] eq "/")} {
5028 - return 1
5026 + if {[string index $p end] eq "/"} {
5027 + if {[string compare -length $l $p $name] == 0} {
5028 + return 1
5029 + }
5030 + } else {
5031 + if {[string compare -length $l $p $name] == 0 &&
5032 + ([string length $name] == $l ||
5033 + [string index $name $l] eq "/")} {
5034 + return 1
5035 + }
5036 }
5037 }
5038 return 0
5039 }
5040
5041 proc addtocflist {ids} {
5035 - global treediffs cflist viewfiles curview limitdiffs
5042 + global treediffs
5043
5037 - if {$limitdiffs && $viewfiles($curview) ne {}} {
5038 - set flist {}
5039 - foreach f $treediffs($ids) {
5040 - if {[path_filter $viewfiles($curview) $f]} {
5041 - lappend flist $f
5042 - }
5043 - }
5044 - } else {
5045 - set flist $treediffs($ids)
5046 - }
5047 - add_flist $flist
5044 + add_flist $treediffs($ids)
5045 getblobdiffs $ids
5046 }
5047
@@ -5100,7 +5097,7 @@ proc gettreediffs {ids} {
5097
5098 proc gettreediffline {gdtf ids} {
5099 global treediff treediffs treepending diffids diffmergeid
5103 - global cmitmode
5100 + global cmitmode viewfiles curview limitdiffs
5101
5102 set nr 0
5103 while {[incr nr] <= 1000 && [gets $gdtf line] >= 0} {
@@ -5117,7 +5114,17 @@ proc gettreediffline {gdtf ids} {
5114 return [expr {$nr >= 1000? 2: 1}]
5115 }
5116 close $gdtf
5120 - set treediffs($ids) $treediff
5117 + if {$limitdiffs && $viewfiles($curview) ne {}} {
5118 + set flist {}
5119 + foreach f $treediff {
5120 + if {[path_filter $viewfiles($curview) $f]} {
5121 + lappend flist $f
5122 + }
5123 + }
5124 + set treediffs($ids) $flist
5125 + } else {
5126 + set treediffs($ids) $treediff
5127 + }
5128 unset treepending
5129 if {$cmitmode eq "tree"} {
5130 gettree $diffids
@@ -7565,7 +7572,7 @@ proc prefscan {} {
7572 proc prefsok {} {
7573 global maxwidth maxgraphpct
7574 global oldprefs prefstop showneartags showlocalchanges
7568 - global charspc ctext tabstop limitdiffs
7575 + global charspc ctext tabstop limitdiffs treediffs
7576
7577 catch {destroy $prefstop}
7578 unset prefstop
@@ -7577,6 +7584,10 @@ proc prefsok {} {
7584 dohidelocalchanges
7585 }
7586 }
7587 + if {$limitdiffs != $oldprefs(limitdiffs)} {
7588 + # treediffs elements are limited by path
7589 + catch {unset treediffs}
7590 + }
7591 if {$maxwidth != $oldprefs(maxwidth)
7592 || $maxgraphpct != $oldprefs(maxgraphpct)} {
7593 redisplay