* [PATCH] git-gui: Move on to the next filename after staging/unstaging a change
@ 2008-06-12 22:12 Abhijit Menon-Sen
2008-06-25 10:36 ` [PATCH] git-gui: Don't select the wrong file if the last listed file is staged Abhijit Menon-Sen
0 siblings, 1 reply; 4+ messages in thread
From: Abhijit Menon-Sen @ 2008-06-12 22:12 UTC (permalink / raw)
To: git; +Cc: gitster, Abhijit Menon-Sen
Suppose the "Unstaged Changes" pane contains a list of files, and one of
them is selected (i.e., that diff is currently being displayed). If one
clicks on the icon to stage the change, git-gui clears the diff and one
has to click on another filename to see the next diff in the list.
This patch changes that behaviour. If one clicks on the icon to stage
(or unstage) the file whose diff is being displayed, git-gui will move
on to the next filename in the list and display that diff instead of a
blank diff pane. If the selected file was at the end of the list, the
diff pane will display the previous diff instead; if the selected file
was the only one listed, the diff pane will become blank.
If no diff is currently being displayed, this patch changes nothing.
Signed-off-by: Abhijit Menon-Sen <ams@toroid.org>
---
git-gui/git-gui.sh | 29 +++++++++++++++++++++++++++--
1 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
index e6e8890..23d7dfe 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -1774,6 +1774,11 @@ proc do_commit {} {
commit_tree
}
+proc next_diff {} {
+ global next_diff_p next_diff_w next_diff_i
+ show_diff $next_diff_p $next_diff_w $next_diff_i
+}
+
proc toggle_or_diff {w x y} {
global file_states file_lists current_diff_path ui_index ui_workdir
global last_clicked selected_paths
@@ -1793,11 +1798,31 @@ proc toggle_or_diff {w x y} {
$ui_workdir tag remove in_sel 0.0 end
if {$col == 0} {
- if {$current_diff_path eq $path} {
+ set i [expr {$lno-1}]
+ set ll [expr {[llength $file_lists($w)]-1}]
+
+ if {$i == $ll && $i == 0} {
set after {reshow_diff;}
} else {
- set after {}
+ global next_diff_p next_diff_w next_diff_i
+
+ if {$i < $ll} {
+ set i [expr {$i + 1}]
+ } else {
+ 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 {}} {
+ set after {next_diff;}
+ } else {
+ set after {}
+ }
}
+
if {$w eq $ui_index} {
update_indexinfo \
"Unstaging [short_path $path] from commit" \
--
1.5.5.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] git-gui: Don't select the wrong file if the last listed file is staged.
2008-06-12 22:12 [PATCH] git-gui: Move on to the next filename after staging/unstaging a change Abhijit Menon-Sen
@ 2008-06-25 10:36 ` Abhijit Menon-Sen
2008-06-25 10:49 ` Johannes Sixt
0 siblings, 1 reply; 4+ messages in thread
From: Abhijit Menon-Sen @ 2008-06-25 10:36 UTC (permalink / raw)
To: git; +Cc: Shawn O. Pearce, Johannes Sixt
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>
---
git-gui/git-gui.sh | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
index 23d7dfe..fe4a4c2 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -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 {}} {
--
1.5.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] git-gui: Don't select the wrong file if the last listed file is staged.
2008-06-25 10:36 ` [PATCH] git-gui: Don't select the wrong file if the last listed file is staged Abhijit Menon-Sen
@ 2008-06-25 10:49 ` Johannes Sixt
2008-06-25 20:57 ` Shawn O. Pearce
0 siblings, 1 reply; 4+ messages in thread
From: Johannes Sixt @ 2008-06-25 10:49 UTC (permalink / raw)
To: Abhijit Menon-Sen; +Cc: git, Shawn O. Pearce
Abhijit Menon-Sen schrieb:
> 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).
Thanks. It works here, too:
Tested-by: Johannes Sixt <johannes.sixt@telecom.at>
-- Hannes
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] git-gui: Don't select the wrong file if the last listed file is staged.
2008-06-25 10:49 ` Johannes Sixt
@ 2008-06-25 20:57 ` Shawn O. Pearce
0 siblings, 0 replies; 4+ messages in thread
From: Shawn O. Pearce @ 2008-06-25 20:57 UTC (permalink / raw)
To: Johannes Sixt; +Cc: Abhijit Menon-Sen, git
Johannes Sixt <j.sixt@viscovery.net> wrote:
> Abhijit Menon-Sen schrieb:
> > 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).
>
> Thanks. It works here, too:
Thanks, both. Its in my tree.
--
Shawn.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-06-25 20:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-12 22:12 [PATCH] git-gui: Move on to the next filename after staging/unstaging a change Abhijit Menon-Sen
2008-06-25 10:36 ` [PATCH] git-gui: Don't select the wrong file if the last listed file is staged Abhijit Menon-Sen
2008-06-25 10:49 ` Johannes Sixt
2008-06-25 20:57 ` Shawn O. Pearce
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).