gitk: Make "find" on "Files" work again.
It was broken by the change to supply just the child id to git-diff-tree rather than both child and parent. Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras committed
Feb 10, 2006 at 10:29 UTC
69d47bdd6c1d6cb9c8603fd1da8b756e2903f955
1 file changed
+34
-48
gitk
+34
-48
@@ -1936,7 +1936,7 @@ proc findfiles {} {
1936
global selectedline numcommits lineid ctext
1937
global ffileline finddidsel parents nparents
1938
global findinprogress findstartline findinsertpos
1939
- global treediffs fdiffids fdiffsneeded fdiffpos
1939
+ global treediffs fdiffid fdiffsneeded fdiffpos
1940
global findmergefiles
1941
1942
if {$numcommits == 0} return
@@ -1953,11 +1953,9 @@ proc findfiles {} {
1953
while 1 {
1954
set id $lineid($l)
1955
if {$findmergefiles || $nparents($id) == 1} {
1956
- foreach p $parents($id) {
1957
- if {![info exists treediffs([list $id $p])]} {
1958
- append diffsneeded "$id $p\n"
1959
- lappend fdiffsneeded [list $id $p]
1960
- }
1956
+ if {![info exists treediffs($id)]} {
1957
+ append diffsneeded "$id\n"
1958
+ lappend fdiffsneeded $id
1959
}
1960
}
1961
if {[incr l] >= $numcommits} {
@@ -1974,7 +1972,7 @@ proc findfiles {} {
1972
error_popup "Error starting search process: $err"
1973
return
1974
}
1977
- catch {unset fdiffids}
1975
+ catch {unset fdiffid}
1976
set fdiffpos 0
1977
fconfigure $df -blocking 0
1978
fileevent $df readable [list readfilediffs $df]
@@ -1983,16 +1981,15 @@ proc findfiles {} {
1981
set finddidsel 0
1982
set findinsertpos end
1983
set id $lineid($l)
1986
- set p [lindex $parents($id) 0]
1984
. config -cursor watch
1985
settextcursor watch
1986
set findinprogress 1
1990
- findcont [list $id $p]
1987
+ findcont $id
1988
update
1989
}
1990
1991
proc readfilediffs {df} {
1995
- global findids fdiffids fdiffs
1992
+ global findid fdiffid fdiffs
1993
1994
set n [gets $df line]
1995
if {$n < 0} {
@@ -2002,19 +1999,19 @@ proc readfilediffs {df} {
1999
stopfindproc
2000
bell
2001
error_popup "Error in git-diff-tree: $err"
2005
- } elseif {[info exists findids]} {
2006
- set ids $findids
2002
+ } elseif {[info exists findid]} {
2003
+ set id $findid
2004
stopfindproc
2005
bell
2009
- error_popup "Couldn't find diffs for {$ids}"
2006
+ error_popup "Couldn't find diffs for $id"
2007
}
2008
}
2009
return
2010
}
2014
- if {[regexp {^([0-9a-f]{40}) \(from ([0-9a-f]{40})\)} $line match id p]} {
2011
+ if {[regexp {^([0-9a-f]{40})$} $line match id]} {
2012
# start of a new string of diffs
2013
donefilediff
2017
- set fdiffids [list $id $p]
2014
+ set fdiffid $id
2015
set fdiffs {}
2016
} elseif {[string match ":*" $line]} {
2017
lappend fdiffs [lindex $line 5]
@@ -2022,53 +2019,50 @@ proc readfilediffs {df} {
2019
}
2020
2021
proc donefilediff {} {
2025
- global fdiffids fdiffs treediffs findids
2022
+ global fdiffid fdiffs treediffs findid
2023
global fdiffsneeded fdiffpos
2024
2028
- if {[info exists fdiffids]} {
2029
- while {[lindex $fdiffsneeded $fdiffpos] ne $fdiffids
2025
+ if {[info exists fdiffid]} {
2026
+ while {[lindex $fdiffsneeded $fdiffpos] ne $fdiffid
2027
&& $fdiffpos < [llength $fdiffsneeded]} {
2028
# git-diff-tree doesn't output anything for a commit
2029
# which doesn't change anything
2033
- set nullids [lindex $fdiffsneeded $fdiffpos]
2034
- set treediffs($nullids) {}
2035
- if {[info exists findids] && $nullids eq $findids} {
2036
- unset findids
2037
- findcont $nullids
2030
+ set nullid [lindex $fdiffsneeded $fdiffpos]
2031
+ set treediffs($nullid) {}
2032
+ if {[info exists findid] && $nullid eq $findid} {
2033
+ unset findid
2034
+ findcont $nullid
2035
}
2036
incr fdiffpos
2037
}
2038
incr fdiffpos
2039
2043
- if {![info exists treediffs($fdiffids)]} {
2044
- set treediffs($fdiffids) $fdiffs
2040
+ if {![info exists treediffs($fdiffid)]} {
2041
+ set treediffs($fdiffid) $fdiffs
2042
}
2046
- if {[info exists findids] && $fdiffids eq $findids} {
2047
- unset findids
2048
- findcont $fdiffids
2043
+ if {[info exists findid] && $fdiffid eq $findid} {
2044
+ unset findid
2045
+ findcont $fdiffid
2046
}
2047
}
2048
}
2049
2053
-proc findcont {ids} {
2054
- global findids treediffs parents nparents
2050
+proc findcont {id} {
2051
+ global findid treediffs parents nparents
2052
global ffileline findstartline finddidsel
2053
global lineid numcommits matchinglines findinprogress
2054
global findmergefiles
2055
2059
- set id [lindex $ids 0]
2060
- set p [lindex $ids 1]
2061
- set pi [lsearch -exact $parents($id) $p]
2056
set l $ffileline
2057
while 1 {
2058
if {$findmergefiles || $nparents($id) == 1} {
2065
- if {![info exists treediffs($ids)]} {
2066
- set findids $ids
2059
+ if {![info exists treediffs($id)]} {
2060
+ set findid $id
2061
set ffileline $l
2062
return
2063
}
2064
set doesmatch 0
2071
- foreach f $treediffs($ids) {
2065
+ foreach f $treediffs($id) {
2066
set x [findmatches $f]
2067
if {$x != {}} {
2068
set doesmatch 1
@@ -2077,21 +2071,13 @@ proc findcont {ids} {
2071
}
2072
if {$doesmatch} {
2073
insertmatch $l $id
2080
- set pi $nparents($id)
2074
}
2082
- } else {
2083
- set pi $nparents($id)
2075
}
2085
- if {[incr pi] >= $nparents($id)} {
2086
- set pi 0
2087
- if {[incr l] >= $numcommits} {
2088
- set l 0
2089
- }
2090
- if {$l == $findstartline} break
2091
- set id $lineid($l)
2076
+ if {[incr l] >= $numcommits} {
2077
+ set l 0
2078
}
2093
- set p [lindex $parents($id) $pi]
2094
- set ids [list $id $p]
2079
+ if {$l == $findstartline} break
2080
+ set id $lineid($l)
2081
}
2082
stopfindproc
2083
if {!$finddidsel} {