{"thread":{"id":"23334","subject":"[PATCH] git-gui: Fast staging/unstaging of hunks/lines","startedAt":"2010-04-05T09:01:24Z","lastAt":"2010-04-12T17:55:08Z","messageCount":6,"participants":["Bert Wesarg","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"138584","messageId":"7ed246d74b2ea872a4af3b99d519590ab17ffefc.1270457921.git.bert.wesarg@googlemail.com","threadId":"23334","inReplyTo":null,"subject":"[PATCH] git-gui: Fast staging/unstaging of hunks/lines","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2010-04-05T09:01:24Z","receivedAt":"2010-04-05T09:01:24Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"This adds a shortcut to stage/unstage hunks or a range of lines. Which is done\non a mouse button 1 release event and holding the control key in the diff view.\nIf there is currently a selection only the selected lines will be staged/unstaged.\nOtherwise the hunk will be staged/unstaged.\n\nSigned-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n---\n git-gui/git-gui.sh |   16 ++++++++++++++++\n 1 files changed, 16 insertions(+), 0 deletions(-)\n\ndiff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh\nindex 7d54511..e65a0e6 100755\n--- a/git-gui/git-gui.sh\n+++ b/git-gui/git-gui.sh\n@@ -3452,6 +3452,22 @@ proc popup_diff_menu {ctxm ctxmmg ctxmsm x y X Y} {\n }\n bind_button3 $ui_diff [list popup_diff_menu $ctxm $ctxmmg $ctxmsm %x %y %X %Y]\n \n+# applies/reverses hunks or lines on button-1 release\n+proc immediate_apply_hunk_or_lines {x y} {\n+\tglobal current_diff_path file_states\n+\tset ::cursorX $x\n+\tset ::cursorY $y\n+\n+\tset has_range [expr {[$::ui_diff tag nextrange sel 0.0] != {}}]\n+\tif {$has_range} {\n+\t\tapply_range_or_line $::cursorX $:cursorY\n+\t\tdo_rescan\n+\t} else {\n+\t\tapply_hunk $::cursorX $::cursorY\n+\t}\n+}\n+bind $ui_diff <$M1B-ButtonRelease-1> {immediate_apply_hunk_or_lines %x %y}\n+\n # -- Status Bar\n #\n set main_status [::status_bar::new .status]\n-- \n1.7.0.3.418.gf56ac.dirty\n"},{"id":"139236","messageId":"x2o36ca99e91004110038oce1ffa15jc49244f228ce218@mail.gmail.com","threadId":"23334","inReplyTo":"7ed246d74b2ea872a4af3b99d519590ab17ffefc.1270457921.git.bert.wesarg@googlemail.com","subject":"Re: [PATCH] git-gui: Fast staging/unstaging of hunks/lines","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2010-04-11T07:38:51Z","receivedAt":"2010-04-11T07:38:51Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"On Mon, Apr 5, 2010 at 11:01, Bert Wesarg <bert.wesarg@googlemail.com> wrote:\n> This adds a shortcut to stage/unstage hunks or a range of lines. Which is done\n> on a mouse button 1 release event and holding the control key in the diff view.\n> If there is currently a selection only the selected lines will be staged/unstaged.\n> Otherwise the hunk will be staged/unstaged.\n\nPing.\n\n>\n> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n> ---\n>  git-gui/git-gui.sh |   16 ++++++++++++++++\n>  1 files changed, 16 insertions(+), 0 deletions(-)\n>\n> diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh\n> index 7d54511..e65a0e6 100755\n> --- a/git-gui/git-gui.sh\n> +++ b/git-gui/git-gui.sh\n> @@ -3452,6 +3452,22 @@ proc popup_diff_menu {ctxm ctxmmg ctxmsm x y X Y} {\n>  }\n>  bind_button3 $ui_diff [list popup_diff_menu $ctxm $ctxmmg $ctxmsm %x %y %X %Y]\n>\n> +# applies/reverses hunks or lines on button-1 release\n> +proc immediate_apply_hunk_or_lines {x y} {\n> +       global current_diff_path file_states\n> +       set ::cursorX $x\n> +       set ::cursorY $y\n> +\n> +       set has_range [expr {[$::ui_diff tag nextrange sel 0.0] != {}}]\n> +       if {$has_range} {\n> +               apply_range_or_line $::cursorX $:cursorY\n> +               do_rescan\n> +       } else {\n> +               apply_hunk $::cursorX $::cursorY\n> +       }\n> +}\n> +bind $ui_diff <$M1B-ButtonRelease-1> {immediate_apply_hunk_or_lines %x %y}\n> +\n>  # -- Status Bar\n>  #\n>  set main_status [::status_bar::new .status]\n> --\n> 1.7.0.3.418.gf56ac.dirty\n>\n>\n"},{"id":"139280","messageId":"201004112101.54908.j6t@kdbg.org","threadId":"23334","inReplyTo":"x2o36ca99e91004110038oce1ffa15jc49244f228ce218@mail.gmail.com","subject":"Re: [PATCH] git-gui: Fast staging/unstaging of hunks/lines","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2010-04-11T19:01:54Z","receivedAt":"2010-04-11T19:01:54Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Sonntag, 11. April 2010, Bert Wesarg wrote:\n> On Mon, Apr 5, 2010 at 11:01, Bert Wesarg <bert.wesarg@googlemail.com> \nwrote:\n> > This adds a shortcut to stage/unstage hunks or a range of lines. Which is\n> > done on a mouse button 1 release event and holding the control key in the\n> > diff view. If there is currently a selection only the selected lines will\n> > be staged/unstaged. Otherwise the hunk will be staged/unstaged.\n>\n> Ping.\n\nI gave the patch a quick try.\n\nI don't think that I would use it a lot because it is very easy to mess up a \nstaged change: The problem is that a click without anything selected will \nstage an entire hunk. I frequently use \"Stage Line(s)\" to separate \nneighboring changes that must go to separate commits, but with you feature it \nis very easy to forget to select something and, hence, to stage the entire \nhunk accidentally - which means that I would have to start over with the hunk \nand all the \"quick\" aspects of the feature would be lost.\n\nThat said, since I don't have Ctrl pressed very often while working in \ngit-gui, the patch wouldn't hurt me, I think.\n\n-- Hannes\n"},{"id":"139309","messageId":"q2m36ca99e91004112349l9e336fffl7e69bb75bce07a40@mail.gmail.com","threadId":"23334","inReplyTo":"201004112101.54908.j6t@kdbg.org","subject":"Re: [PATCH] git-gui: Fast staging/unstaging of hunks/lines","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2010-04-12T06:49:01Z","receivedAt":"2010-04-12T06:49:01Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"Hi,\n\nOn Sun, Apr 11, 2010 at 21:01, Johannes Sixt <j6t@kdbg.org> wrote:\n> On Sonntag, 11. April 2010, Bert Wesarg wrote:\n>> On Mon, Apr 5, 2010 at 11:01, Bert Wesarg <bert.wesarg@googlemail.com>\n> wrote:\n>> > This adds a shortcut to stage/unstage hunks or a range of lines. Which is\n>> > done on a mouse button 1 release event and holding the control key in the\n>> > diff view. If there is currently a selection only the selected lines will\n>> > be staged/unstaged. Otherwise the hunk will be staged/unstaged.\n>>\n>> Ping.\n>\n> I gave the patch a quick try.\n\nThanks,\n\n>\n> I don't think that I would use it a lot because it is very easy to mess up a\n> staged change: The problem is that a click without anything selected will\n> stage an entire hunk. I frequently use \"Stage Line(s)\" to separate\n> neighboring changes that must go to separate commits, but with you feature it\n> is very easy to forget to select something and, hence, to stage the entire\n> hunk accidentally - which means that I would have to start over with the hunk\n> and all the \"quick\" aspects of the feature would be lost.\n\nI don't feel comfortable with this ambiguity myself. I see two ways to\nsolve this:\n\n    a) Use Shift-Button-1 for lines\n\nor\n\n    b) Use Shift-Control-Button-1 for lines\n\nand make Control-Button-1 only stage hunks.\n\nMay this interface be more usable?\n\nRegards,\nBert\n\n> -- Hannes\n>\n"},{"id":"139362","messageId":"201004121945.16216.j6t@kdbg.org","threadId":"23334","inReplyTo":"q2m36ca99e91004112349l9e336fffl7e69bb75bce07a40@mail.gmail.com","subject":"Re: [PATCH] git-gui: Fast staging/unstaging of hunks/lines","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2010-04-12T17:45:16Z","receivedAt":"2010-04-12T17:45:16Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Montag, 12. April 2010, Bert Wesarg wrote:\n> I don't feel comfortable with this ambiguity myself. I see two ways to\n> solve this:\n>\n>     a) Use Shift-Button-1 for lines\n>\n> or\n>\n>     b) Use Shift-Control-Button-1 for lines\n>\n> and make Control-Button-1 only stage hunks.\n\nThat's worse, because you need Shift-Button-1 to extend a selection.\n\nThe problem is that the X-Windowsy way to overload single-click operations. \nPersonally, I prefer to get an operative response only on double-click. It's \nstill unused, I think.\n\n-- Hannes\n"},{"id":"139363","messageId":"j2s36ca99e91004121055x5cb37d3er423bdfda5aa70702@mail.gmail.com","threadId":"23334","inReplyTo":"201004121945.16216.j6t@kdbg.org","subject":"Re: [PATCH] git-gui: Fast staging/unstaging of hunks/lines","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2010-04-12T17:55:08Z","receivedAt":"2010-04-12T17:55:08Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"On Mon, Apr 12, 2010 at 19:45, Johannes Sixt <j6t@kdbg.org> wrote:\n> On Montag, 12. April 2010, Bert Wesarg wrote:\n>> I don't feel comfortable with this ambiguity myself. I see two ways to\n>> solve this:\n>>\n>>     a) Use Shift-Button-1 for lines\n>>\n>> or\n>>\n>>     b) Use Shift-Control-Button-1 for lines\n>>\n>> and make Control-Button-1 only stage hunks.\n>\n> That's worse, because you need Shift-Button-1 to extend a selection.\n>\n> The problem is that the X-Windowsy way to overload single-click operations.\n> Personally, I prefer to get an operative response only on double-click. It's\n> still unused, I think.\n\nGood idea. But I fear that you can loose your selection, if you move\nthe pointer accidentally while double clicking. Its still worth to try\nthis.\n\nBert\n\n>\n> -- Hannes\n>\n"}]}