git-gui: Maintain the same file list for diff during refresh.
I just noticed that a file was always jumping to compare against HEAD and the index during a refresh, even if the diff viewer was comparing the index against the working directory prior to the refresh. The bug turned out to be caused by a foreach loop going through all file list names searching for the path. Since $ui_index was the first one searched and the file was contained in that file list the loop broke out, leaving $w set to $ui_index when it had been set by the caller to $ui_workdir. Silly bug caused by using a parameter as a loop index. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Jan 25, 2007 at 21:33 UTC
5f8b70b1dc3d149782564e04d5d55565a5157d93
1 file changed
+5
-8
git-gui.sh
+5
-8
@@ -607,16 +607,13 @@ proc show_diff {path w {lno {}}} {
607
if {$diff_active || ![lock_index read]} return
608
609
clear_diff
610
- if {$w eq {} || $lno == {}} {
611
- foreach w [array names file_lists] {
612
- set lno [lsearch -sorted $file_lists($w) $path]
613
- if {$lno >= 0} {
614
- incr lno
615
- break
616
- }
610
+ if {$lno == {}} {
611
+ set lno [lsearch -sorted $file_lists($w) $path]
612
+ if {$lno >= 0} {
613
+ incr lno
614
}
615
}
619
- if {$w ne {} && $lno >= 1} {
616
+ if {$lno >= 1} {
617
$w tag add in_diff $lno.0 [expr {$lno + 1}].0
618
}
619