{"thread":{"id":"13920","subject":"[PATCH] git-gui: Move on to the next filename after staging/unstaging a change","startedAt":"2008-06-12T22:12:10Z","lastAt":"2008-06-25T20:57:02Z","messageCount":4,"participants":["Abhijit Menon-Sen","Johannes Sixt","Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"79649","messageId":"1213308730-12707-1-git-send-email-ams@toroid.org","threadId":"13920","inReplyTo":null,"subject":"[PATCH] git-gui: Move on to the next filename after staging/unstaging a change","fromName":"Abhijit Menon-Sen","fromEmail":"ams@toroid.org","sentAt":"2008-06-12T22:12:10Z","receivedAt":"2008-06-12T22:12:10Z","isPatch":true,"sender":{"key":"ams@toroid.org","avatar":null},"body":"Suppose the \"Unstaged Changes\" pane contains a list of files, and one of\nthem is selected (i.e., that diff is currently being displayed). If one\nclicks on the icon to stage the change, git-gui clears the diff and one\nhas to click on another filename to see the next diff in the list.\n\nThis patch changes that behaviour. If one clicks on the icon to stage\n(or unstage) the file whose diff is being displayed, git-gui will move\non to the next filename in the list and display that diff instead of a\nblank diff pane. If the selected file was at the end of the list, the\ndiff pane will display the previous diff instead; if the selected file\nwas the only one listed, the diff pane will become blank.\n\nIf no diff is currently being displayed, this patch changes nothing.\n\nSigned-off-by: Abhijit Menon-Sen <ams@toroid.org>\n---\n git-gui/git-gui.sh |   29 +++++++++++++++++++++++++++--\n 1 files changed, 27 insertions(+), 2 deletions(-)\n\ndiff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh\nindex e6e8890..23d7dfe 100755\n--- a/git-gui/git-gui.sh\n+++ b/git-gui/git-gui.sh\n@@ -1774,6 +1774,11 @@ proc do_commit {} {\n \tcommit_tree\n }\n \n+proc next_diff {} {\n+\tglobal next_diff_p next_diff_w next_diff_i\n+\tshow_diff $next_diff_p $next_diff_w $next_diff_i\n+}\n+\n proc toggle_or_diff {w x y} {\n \tglobal file_states file_lists current_diff_path ui_index ui_workdir\n \tglobal last_clicked selected_paths\n@@ -1793,11 +1798,31 @@ proc toggle_or_diff {w x y} {\n \t$ui_workdir tag remove in_sel 0.0 end\n \n \tif {$col == 0} {\n-\t\tif {$current_diff_path eq $path} {\n+\t\tset i [expr {$lno-1}]\n+\t\tset ll [expr {[llength $file_lists($w)]-1}]\n+\n+\t\tif {$i == $ll && $i == 0} {\n \t\t\tset after {reshow_diff;}\n \t\t} else {\n-\t\t\tset after {}\n+\t\t\tglobal next_diff_p next_diff_w next_diff_i\n+\n+\t\t\tif {$i < $ll} {\n+\t\t\t\tset i [expr {$i + 1}]\n+\t\t\t} else {\n+\t\t\t\tset i [expr {$i - 1}]\n+\t\t\t}\n+\n+\t\t\tset next_diff_i $i\n+\t\t\tset next_diff_w $w\n+\t\t\tset next_diff_p [lindex $file_lists($w) $i]\n+\n+\t\t\tif {$next_diff_p ne {} && $current_diff_path ne {}} {\n+\t\t\t\tset after {next_diff;}\n+\t\t\t} else {\n+\t\t\t\tset after {}\n+\t\t\t}\n \t\t}\n+\n \t\tif {$w eq $ui_index} {\n \t\t\tupdate_indexinfo \\\n \t\t\t\t\"Unstaging [short_path $path] from commit\" \\\n-- \n1.5.5.1\n"},{"id":"81107","messageId":"20080625103650.GA20492@toroid.org","threadId":"13920","inReplyTo":"1213308730-12707-1-git-send-email-ams@toroid.org","subject":"[PATCH] git-gui: Don't select the wrong file if the last listed file is staged.","fromName":"Abhijit Menon-Sen","fromEmail":"ams@toroid.org","sentAt":"2008-06-25T10:36:50Z","receivedAt":"2008-06-25T10:36:50Z","isPatch":true,"sender":{"key":"ams@toroid.org","avatar":null},"body":"Johannes Sixt noticed that if the last file in the list was staged, my\nearlier patch would display the diff for the penultimate file, but show\nthe file _before_ that as being selected.\n\nThis was due to my misunderstanding the lno argument to show_diff.\n\nThis patch fixes the problem: lno is not decremented in the special case\nto handle the last item in the list (though we still need to use $lno-1\nto find the right path for the next diff).\n\nSigned-off-by: Abhijit Menon-Sen <ams@toroid.org>\n---\n git-gui/git-gui.sh |    6 ++++--\n 1 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh\nindex 23d7dfe..fe4a4c2 100755\n--- a/git-gui/git-gui.sh\n+++ b/git-gui/git-gui.sh\n@@ -1806,14 +1806,16 @@ proc toggle_or_diff {w x y} {\n \t\t} else {\n \t\t\tglobal next_diff_p next_diff_w next_diff_i\n \n+\t\t\tset next_diff_w $w\n+\n \t\t\tif {$i < $ll} {\n \t\t\t\tset i [expr {$i + 1}]\n+\t\t\t\tset next_diff_i $i\n \t\t\t} else {\n+\t\t\t\tset next_diff_i $i\n \t\t\t\tset i [expr {$i - 1}]\n \t\t\t}\n \n-\t\t\tset next_diff_i $i\n-\t\t\tset next_diff_w $w\n \t\t\tset next_diff_p [lindex $file_lists($w) $i]\n \n \t\t\tif {$next_diff_p ne {} && $current_diff_path ne {}} {\n-- \n1.5.6\n"},{"id":"81110","messageId":"486222A6.70205@viscovery.net","threadId":"13920","inReplyTo":"20080625103650.GA20492@toroid.org","subject":"Re: [PATCH] git-gui: Don't select the wrong file if the last listed file is staged.","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-06-25T10:49:10Z","receivedAt":"2008-06-25T10:49:10Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Abhijit Menon-Sen schrieb:\n> Johannes Sixt noticed that if the last file in the list was staged, my\n> earlier patch would display the diff for the penultimate file, but show\n> the file _before_ that as being selected.\n> \n> This was due to my misunderstanding the lno argument to show_diff.\n> \n> This patch fixes the problem: lno is not decremented in the special case\n> to handle the last item in the list (though we still need to use $lno-1\n> to find the right path for the next diff).\n\nThanks. It works here, too:\n\nTested-by: Johannes Sixt <johannes.sixt@telecom.at>\n\n-- Hannes\n"},{"id":"81188","messageId":"20080625205702.GN11793@spearce.org","threadId":"13920","inReplyTo":"486222A6.70205@viscovery.net","subject":"Re: [PATCH] git-gui: Don't select the wrong file if the last listed file is staged.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-06-25T20:57:02Z","receivedAt":"2008-06-25T20:57:02Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Johannes Sixt <j.sixt@viscovery.net> wrote:\n> Abhijit Menon-Sen schrieb:\n> > Johannes Sixt noticed that if the last file in the list was staged, my\n> > earlier patch would display the diff for the penultimate file, but show\n> > the file _before_ that as being selected.\n> > \n> > This was due to my misunderstanding the lno argument to show_diff.\n> > \n> > This patch fixes the problem: lno is not decremented in the special case\n> > to handle the last item in the list (though we still need to use $lno-1\n> > to find the right path for the next diff).\n> \n> Thanks. It works here, too:\n\nThanks, both.  Its in my tree.\n \n-- \nShawn.\n"}]}