@matheusbsbs / matheus-bagliano / commits / f531e463f0
Fork 0

git-gui: Don't select the wrong file if the last listed file is staged.

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>

Abhijit Menon-Sen committed Jun 25, 2008 at 16:06 UTC f531e463f0471ce41c51e19074a118482f36910f
1 file changed +4 -2
git-gui.sh
+4 -2
@@ -1806,14 +1806,16 @@ proc toggle_or_diff {w x y} {
1806 } else {
1807 global next_diff_p next_diff_w next_diff_i
1808
1809 + set next_diff_w $w
1810 +
1811 if {$i < $ll} {
1812 set i [expr {$i + 1}]
1813 + set next_diff_i $i
1814 } else {
1815 + set next_diff_i $i
1816 set i [expr {$i - 1}]
1817 }
1818
1815 - set next_diff_i $i
1816 - set next_diff_w $w
1819 set next_diff_p [lindex $file_lists($w) $i]
1820
1821 if {$next_diff_p ne {} && $current_diff_path ne {}} {