Skip to content

Commit

Permalink
git-gui: Don't select the wrong file if the last listed file is staged.
Browse files Browse the repository at this point in the history
Johannes Sixt noticed that if the last file in the list was staged, my
earlier patch would display the diff for the penultimate file, but show
the file _before_ that as being selected.

This was due to my misunderstanding the lno argument to show_diff.

This patch fixes the problem: lno is not decremented in the special case
to handle the last item in the list (though we still need to use $lno-1
to find the right path for the next diff).

Signed-off-by: Abhijit Menon-Sen <ams@toroid.org>
Tested-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
  • Loading branch information
Abhijit Menon-Sen authored and Shawn O. Pearce committed Jun 25, 2008
1 parent cead78e commit f531e46
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions git-gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1806,14 +1806,16 @@ proc toggle_or_diff {w x y} {
} else {
global next_diff_p next_diff_w next_diff_i
set next_diff_w $w
if {$i < $ll} {
set i [expr {$i + 1}]
set next_diff_i $i
} else {
set next_diff_i $i
set i [expr {$i - 1}]
}
set next_diff_i $i
set next_diff_w $w
set next_diff_p [lindex $file_lists($w) $i]
if {$next_diff_p ne {} && $current_diff_path ne {}} {
Expand Down

0 comments on commit f531e46

Please sign in to comment.