threads / discuss / 51782

feature request, git-gui: add hotkey to toggle amend/new

Subject: feature request, git-gui: add hotkey to toggle amend/new

## tl;dr

27 messages between Aug 31, 2019 and Sep 11, 2019.

replies: 26people: 6as markdown or json

Birger Skogeng Pedersen· Aug 31, 2019, 10:51 UTC · lore

In my pursuit to fully utilize git-gui with only using a keyboard, I suggest that there is a hotkey to toggle between selecting "New Commit" and "Amend Last Commit".

Not sure which key-combination that fits this purpose best, but my suggestion is CTRL/CMD+Z.

Best regards, Birger

Birger Skogeng Pedersen· Sep 2, 2019, 16:25 UTC · re: Birger Skogeng Pedersen · lore

Re: feature request, git-gui: add hotkey to toggle amend/new

I just now realized what a terrible suggestion CTRL+Z was. I propose CTRL/CMD+E to toggle between amend/new commit.

On Sat, Aug 31, 2019 at 12:51 PM Birger Skogeng Pedersen <birger.sp@gmail.com> wrote:

Show 10 quoted lines
>
> In my pursuit to fully utilize git-gui with only using a keyboard, I
> suggest that there is a hotkey to toggle between selecting "New
> Commit" and "Amend Last Commit".
>
> Not sure which key-combination that fits this purpose best, but my
> suggestion is CTRL/CMD+Z.
>
> Best regards,
> Birger
Bert Wesarg· Sep 2, 2019, 18:07 UTC · re: Birger Skogeng Pedersen · lore

Re: feature request, git-gui: add hotkey to toggle amend/new

Birger,

On Mon, Sep 2, 2019 at 6:25 PM Birger Skogeng Pedersen <birger.sp@gmail.com> wrote:

Show 13 quoted lines
>
> I just now realized what a terrible suggestion CTRL+Z was.
> I propose CTRL/CMD+E to toggle between amend/new commit.
>
> On Sat, Aug 31, 2019 at 12:51 PM Birger Skogeng Pedersen
> <birger.sp@gmail.com> wrote:
> >
> > In my pursuit to fully utilize git-gui with only using a keyboard, I
> > suggest that there is a hotkey to toggle between selecting "New
> > Commit" and "Amend Last Commit".
> >
> > Not sure which key-combination that fits this purpose best, but my
> > suggestion is CTRL/CMD+Z.
I think with your "focus" patch, this is not needed anymore:

After focusing the commit message widget, you can focus the radio buttons with Tab/Shift+Tab and press Space.

I think this is short enough, so that wasting a Letter is not justified here.

Best, Bert

> >
> > Best regards,
> > Birger
Birger Skogeng Pedersen· Sep 2, 2019, 19:49 UTC · re: Bert Wesarg · lore

Re: feature request, git-gui: add hotkey to toggle amend/new

Hi Bert,
On Mon, Sep 2, 2019 at 8:08 PM Bert Wesarg <bert.wesarg@googlemail.com> wrote:
Show 6 quoted lines
> I think with your "focus" patch, this is not needed anymore:
>
> After focusing the commit message widget, you can focus the radio
> buttons with Tab/Shift+Tab and press Space.
>
> I think this is short enough, so that wasting a Letter is not justified here.

Pressing the Tab key while the commit message widget is focused inserts a tab in the commit message. (Again, I'm on Windows so you might get different behaviour on Linux)

If the Tab key acted like you suggested, I agree it would not be necessary with this a hotkey like this.

Best regards, Birger

Birger Skogeng Pedersen· Sep 2, 2019, 19:56 UTC · re: Birger Skogeng Pedersen · lore

[PATCH] Add hotkey to toggle "Amend Last Commit" radio selector

Selecting whether to do a "New Commit" or "Amend Last Commit" does not have a hotkey.

With this patch, the user may toggle between the two options with CTRL/CMD+e.

Signed-off-by: Birger Skogeng Pedersen <birger.sp@gmail.com>
---
 git-gui.sh | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff --git a/git-gui.sh b/git-gui.sh
index 5bc21b8..14be1e0 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -2640,6 +2640,16 @@ proc show_less_context {} {
 	}
 }
 
+proc toggle_commit_type {} {
+	global selected_commit_type
+	if {[string match amend* $selected_commit_type]} {
+		set selected_commit_type new
+	} else {
+		set selected_commit_type amend
+	}
+	do_select_commit_type
+}
+
 ######################################################################
 ##
 ## ui construction
@@ -3843,6 +3853,7 @@ bind .   <$M1B-Key-equal> {show_more_context;break}
 bind .   <$M1B-Key-plus> {show_more_context;break}
 bind .   <$M1B-Key-KP_Add> {show_more_context;break}
 bind .   <$M1B-Key-Return> do_commit
+bind .   <$M1B-Key-e> toggle_commit_type
 foreach i [list $ui_index $ui_workdir] {
 	bind $i <Button-1>       { toggle_or_diff click %W %x %y; break }
 	bind $i <$M1B-Button-1>  { add_one_to_selection %W %x %y; break }
-- 
2.21.0.windows.1
Bert Wesarg· Sep 3, 2019, 08:52 UTC · re: Birger Skogeng Pedersen · lore

Re: [PATCH] Add hotkey to toggle "Amend Last Commit" radio selector

Birger,

On Mon, Sep 2, 2019 at 9:56 PM Birger Skogeng Pedersen <birger.sp@gmail.com> wrote:

Show 6 quoted lines
>
> Selecting whether to do a "New Commit" or "Amend Last Commit" does not have
> a hotkey.
>
> With this patch, the user may toggle between the two options with
> CTRL/CMD+e.

David A. (in Cc from git-cola) suggested, that we try to re-use existing key bindings in Git GUIs. Here is Git-Cola hotkeys:

http://git-cola.github.io/share/doc/git-cola/hotkeys.html

and this indicates, that it already uses CTRL+m for "amend". Though I'm unsure if this is a toggle like in git-gui or a one-shot. David A., can you please clarify?

Show 32 quoted lines
>
> Signed-off-by: Birger Skogeng Pedersen <birger.sp@gmail.com>
> ---
>  git-gui.sh | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/git-gui.sh b/git-gui.sh
> index 5bc21b8..14be1e0 100755
> --- a/git-gui.sh
> +++ b/git-gui.sh
> @@ -2640,6 +2640,16 @@ proc show_less_context {} {
>         }
>  }
>
> +proc toggle_commit_type {} {
> +       global selected_commit_type
> +       if {[string match amend* $selected_commit_type]} {
> +               set selected_commit_type new
> +       } else {
> +               set selected_commit_type amend
> +       }
> +       do_select_commit_type
> +}
> +
>  ######################################################################
>  ##
>  ## ui construction
> @@ -3843,6 +3853,7 @@ bind .   <$M1B-Key-equal> {show_more_context;break}
>  bind .   <$M1B-Key-plus> {show_more_context;break}
>  bind .   <$M1B-Key-KP_Add> {show_more_context;break}
>  bind .   <$M1B-Key-Return> do_commit
> +bind .   <$M1B-Key-e> toggle_commit_type

The commit type has also a two toggle menu entries (under "Commit") they should now also indicate the key binding. disable

Though how to express a toggle keybinding in the menu? I don't know if you can assign the same keybinding to the same menu entry. Maybe we need to add/remove the keybinding depending on the current mode.

Bert
Show 6 quoted lines
>  foreach i [list $ui_index $ui_workdir] {
>         bind $i <Button-1>       { toggle_or_diff click %W %x %y; break }
>         bind $i <$M1B-Button-1>  { add_one_to_selection %W %x %y; break }
> --
> 2.21.0.windows.1
>
Bert Wesarg· Sep 3, 2019, 10:25 UTC · re: Bert Wesarg · lore

Re: [PATCH] Add hotkey to toggle "Amend Last Commit" radio selector

David,
On Tue, Sep 3, 2019 at 10:52 AM Bert Wesarg <bert.wesarg@googlemail.com> wrote:
Show 20 quoted lines
>
> Birger,
>
> On Mon, Sep 2, 2019 at 9:56 PM Birger Skogeng Pedersen
> <birger.sp@gmail.com> wrote:
> >
> > Selecting whether to do a "New Commit" or "Amend Last Commit" does not have
> > a hotkey.
> >
> > With this patch, the user may toggle between the two options with
> > CTRL/CMD+e.
>
> David A. (in Cc from git-cola) suggested, that we try to re-use
> existing key bindings in Git GUIs. Here is Git-Cola hotkeys:
>
> http://git-cola.github.io/share/doc/git-cola/hotkeys.html
>
> and this indicates, that it already uses CTRL+m for "amend". Though
> I'm unsure if this is a toggle like in git-gui or a one-shot. David
> A., can you please clarify?
git-gui already assigns CTRL+m to "Local merge…"
sorry. I think trying to synchronize the keybindings seems impossible.
Bert
Show 50 quoted lines
>
> >
> > Signed-off-by: Birger Skogeng Pedersen <birger.sp@gmail.com>
> > ---
> >  git-gui.sh | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> >
> > diff --git a/git-gui.sh b/git-gui.sh
> > index 5bc21b8..14be1e0 100755
> > --- a/git-gui.sh
> > +++ b/git-gui.sh
> > @@ -2640,6 +2640,16 @@ proc show_less_context {} {
> >         }
> >  }
> >
> > +proc toggle_commit_type {} {
> > +       global selected_commit_type
> > +       if {[string match amend* $selected_commit_type]} {
> > +               set selected_commit_type new
> > +       } else {
> > +               set selected_commit_type amend
> > +       }
> > +       do_select_commit_type
> > +}
> > +
> >  ######################################################################
> >  ##
> >  ## ui construction
> > @@ -3843,6 +3853,7 @@ bind .   <$M1B-Key-equal> {show_more_context;break}
> >  bind .   <$M1B-Key-plus> {show_more_context;break}
> >  bind .   <$M1B-Key-KP_Add> {show_more_context;break}
> >  bind .   <$M1B-Key-Return> do_commit
> > +bind .   <$M1B-Key-e> toggle_commit_type
>
> The commit type has also a two toggle menu entries (under "Commit")
> they should now also indicate the key binding.
> disable
>
> Though how to express a toggle keybinding in the menu? I don't know if
> you can assign the same keybinding to the same menu entry. Maybe we
> need to add/remove the keybinding depending on the current mode.
>
> Bert
>
> >  foreach i [list $ui_index $ui_workdir] {
> >         bind $i <Button-1>       { toggle_or_diff click %W %x %y; break }
> >         bind $i <$M1B-Button-1>  { add_one_to_selection %W %x %y; break }
> > --
> > 2.21.0.windows.1
> >
Bert Wesarg· Sep 3, 2019, 16:20 UTC · re: Bert Wesarg · lore

Re: [PATCH] Add hotkey to toggle "Amend Last Commit" radio selector

Birger,
On Tue, Sep 3, 2019 at 10:52 AM Bert Wesarg <bert.wesarg@googlemail.com> wrote:
Show 61 quoted lines
>
> Birger,
>
> On Mon, Sep 2, 2019 at 9:56 PM Birger Skogeng Pedersen
> <birger.sp@gmail.com> wrote:
> >
> > Selecting whether to do a "New Commit" or "Amend Last Commit" does not have
> > a hotkey.
> >
> > With this patch, the user may toggle between the two options with
> > CTRL/CMD+e.
>
> David A. (in Cc from git-cola) suggested, that we try to re-use
> existing key bindings in Git GUIs. Here is Git-Cola hotkeys:
>
> http://git-cola.github.io/share/doc/git-cola/hotkeys.html
>
> and this indicates, that it already uses CTRL+m for "amend". Though
> I'm unsure if this is a toggle like in git-gui or a one-shot. David
> A., can you please clarify?
>
> >
> > Signed-off-by: Birger Skogeng Pedersen <birger.sp@gmail.com>
> > ---
> >  git-gui.sh | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> >
> > diff --git a/git-gui.sh b/git-gui.sh
> > index 5bc21b8..14be1e0 100755
> > --- a/git-gui.sh
> > +++ b/git-gui.sh
> > @@ -2640,6 +2640,16 @@ proc show_less_context {} {
> >         }
> >  }
> >
> > +proc toggle_commit_type {} {
> > +       global selected_commit_type
> > +       if {[string match amend* $selected_commit_type]} {
> > +               set selected_commit_type new
> > +       } else {
> > +               set selected_commit_type amend
> > +       }
> > +       do_select_commit_type
> > +}
> > +
> >  ######################################################################
> >  ##
> >  ## ui construction
> > @@ -3843,6 +3853,7 @@ bind .   <$M1B-Key-equal> {show_more_context;break}
> >  bind .   <$M1B-Key-plus> {show_more_context;break}
> >  bind .   <$M1B-Key-KP_Add> {show_more_context;break}
> >  bind .   <$M1B-Key-Return> do_commit
> > +bind .   <$M1B-Key-e> toggle_commit_type
>
> The commit type has also a two toggle menu entries (under "Commit")
> they should now also indicate the key binding.
> disable
>
> Though how to express a toggle keybinding in the menu? I don't know if
> you can assign the same keybinding to the same menu entry. Maybe we
> need to add/remove the keybinding depending on the current mode.

that works. I squashed this into your commit and pushed to GitHub (sorry, still no path-per-mail)

https://github.com/bertwesarg/git-gui/commit/245bb9944e3d1c6b266c58b56d316f283ed3516b
Bert
Show 9 quoted lines
>
> Bert
>
> >  foreach i [list $ui_index $ui_workdir] {
> >         bind $i <Button-1>       { toggle_or_diff click %W %x %y; break }
> >         bind $i <$M1B-Button-1>  { add_one_to_selection %W %x %y; break }
> > --
> > 2.21.0.windows.1
> >
Bert Wesarg· Sep 2, 2019, 20:12 UTC · re: Birger Skogeng Pedersen · lore

Re: feature request, git-gui: add hotkey to toggle amend/new

On Mon, Sep 2, 2019 at 9:49 PM Birger Skogeng Pedersen <birger.sp@gmail.com> wrote:

Show 18 quoted lines
>
> Hi Bert,
>
>
> On Mon, Sep 2, 2019 at 8:08 PM Bert Wesarg <bert.wesarg@googlemail.com> wrote:
> > I think with your "focus" patch, this is not needed anymore:
> >
> > After focusing the commit message widget, you can focus the radio
> > buttons with Tab/Shift+Tab and press Space.
> >
> > I think this is short enough, so that wasting a Letter is not justified here.
>
> Pressing the Tab key while the commit message widget is focused
> inserts a tab in the commit message.
> (Again, I'm on Windows so you might get different behaviour on Linux)
>
> If the Tab key acted like you suggested, I agree it would not be
> necessary with this a hotkey like this.
can we try to figure this out, before going forward with anything else?
Thanks.
Bert
>
>
> Best regards,
> Birger
Bert Wesarg· Sep 2, 2019, 20:15 UTC · re: Bert Wesarg · lore

Re: feature request, git-gui: add hotkey to toggle amend/new

On Mon, Sep 2, 2019 at 10:12 PM Bert Wesarg <bert.wesarg@googlemail.com> wrote:
Show 17 quoted lines
>
> On Mon, Sep 2, 2019 at 9:49 PM Birger Skogeng Pedersen
> <birger.sp@gmail.com> wrote:
> >
> > Hi Bert,
> >
> >
> > On Mon, Sep 2, 2019 at 8:08 PM Bert Wesarg <bert.wesarg@googlemail.com> wrote:
> > > I think with your "focus" patch, this is not needed anymore:
> > >
> > > After focusing the commit message widget, you can focus the radio
> > > buttons with Tab/Shift+Tab and press Space.
> > >
> > > I think this is short enough, so that wasting a Letter is not justified here.
> >
> > Pressing the Tab key while the commit message widget is focused
> > inserts a tab in the commit message.
does Control-Tab works for traversal?
Show 15 quoted lines
> > (Again, I'm on Windows so you might get different behaviour on Linux)
> >
> > If the Tab key acted like you suggested, I agree it would not be
> > necessary with this a hotkey like this.
>
> can we try to figure this out, before going forward with anything else?
>
> Thanks.
>
> Bert
>
> >
> >
> > Best regards,
> > Birger
Birger Skogeng Pedersen· Sep 3, 2019, 05:37 UTC · re: Bert Wesarg · lore

Re: feature request, git-gui: add hotkey to toggle amend/new

On Mon, Sep 2, 2019 at 10:15 PM Bert Wesarg <bert.wesarg@googlemail.com> wrote:
> does Control-Tab works for traversal?
Bert,

Control+Tab works for traversal, but as a means to toggle new/amend it's very tedious. I have to press Ctrl+Tab 9 times to select "new" and 10 times to select "Amend"(!). Then 1 or 2 more times to go back to the input area. I sincerely doubt that this is your preferred method of switching between new/amend. At this point we're better of letting go of the keyboard and use the mouse, which is what I'm trying to avoid.

> I think this is short enough, so that wasting a Letter is not justified here.

I (also) often amend commits, so having a hotkey for this is quite a necessity imo.

Birger
Pratyush Yadav· Sep 3, 2019, 12:45 UTC · re: Birger Skogeng Pedersen · lore

Re: feature request, git-gui: add hotkey to toggle amend/new

On 03/09/19 07:37AM, Birger Skogeng Pedersen wrote:
Show 13 quoted lines
> On Mon, Sep 2, 2019 at 10:15 PM Bert Wesarg <bert.wesarg@googlemail.com> wrote:
> > does Control-Tab works for traversal?
> 
> 
> Bert,
> 
> Control+Tab works for traversal, but as a means to toggle new/amend
> it's very tedious. I have to press Ctrl+Tab 9 times to select "new"
> and 10 times to select "Amend"(!). Then 1 or 2 more times to go back
> to the input area.
> I sincerely doubt that this is your preferred method of switching
> between new/amend. At this point we're better of letting go of the
> keyboard and use the mouse, which is what I'm trying to avoid.
 
Can you try doing a Shift+Tab? For me on Linux, if I hit Shift+Tab, it 
immediately takes me to the "Amend last commit" option. Then I can press 
space to select it and Tab again to get back to the commit message.

Also, since we are on this topic, how about making the "Amend last commit" button a toggle instead? This would act as a "turn amend mode on/off" button. Since "Amend last commit" and "New Commit" are mutually exclusive, a single toggle to switch between those modes makes sense to me.

> > I think this is short enough, so that wasting a Letter is not 
> > justified here.
> I (also) often amend commits, so having a hotkey for this is quite a
> necessity imo.

Assuming the above works for you, do you still feel the need for a dedicated binding for amends?

-- 
Regards,
Pratyush Yadav
Birger Skogeng Pedersen· Sep 3, 2019, 14:06 UTC · re: Pratyush Yadav · lore

Re: feature request, git-gui: add hotkey to toggle amend/new

Hi Pratyush,
On Tue, Sep 3, 2019 at 2:45 PM Pratyush Yadav <me@yadavpratyush.com> wrote:
> Can you try doing a Shift+Tab? For me on Linux, if I hit Shift+Tab, it
> immediately takes me to the "Amend last commit" option. Then I can press
> space to select it and Tab again to get back to the commit message.

It seems that Shift+Tab doesn't do anything (on Windows 10). Regardless, imo there should be a binding dedicated to toggle amend.

Show 5 quoted lines
> Also, since we are on this topic, how about making the "Amend last
> commit" button a toggle instead? This would act as a "turn amend mode
> on/off" button. Since "Amend last commit" and "New Commit" are mutually
> exclusive, a single toggle to switch between those modes makes sense to
> me.

I assume you're talking about the button in the "Commit" dropdown menu. I agree, it could be just a single entry which is a toggle to enable/disable amending. And (above the commit message dialog) perhaps just a single checkbox; "Amend Last Commit". In other git GUIs (Git Cola and TortoiseGit) I see they're using just a single checkbox for this option. But maybe that is a slightly different topic, the hotkey behaviour would remain the same.

> ... do you still feel the need for a dedicated binding for amends?

How do you guys feel about it? So far it seems we're at two "yay" and one "nay". I really feel it is in the best interest of the git-gui project to implement this hotkey. And not just because it is my personal preference to have it :-)

Birger
Pratyush Yadav· Sep 3, 2019, 17:34 UTC · re: Birger Skogeng Pedersen · lore

Re: feature request, git-gui: add hotkey to toggle amend/new

On 03/09/19 04:06PM, Birger Skogeng Pedersen wrote:
Show 9 quoted lines
> Hi Pratyush,
> 
> 
> On Tue, Sep 3, 2019 at 2:45 PM Pratyush Yadav <me@yadavpratyush.com> wrote:
> > Can you try doing a Shift+Tab? For me on Linux, if I hit Shift+Tab, it
> > immediately takes me to the "Amend last commit" option. Then I can press
> > space to select it and Tab again to get back to the commit message.
> 
> It seems that Shift+Tab doesn't do anything (on Windows 10).
Ah, too bad.
Show 9 quoted lines
> Regardless, imo there should be a binding dedicated to toggle amend.
> 
> > Also, since we are on this topic, how about making the "Amend last
> > commit" button a toggle instead? This would act as a "turn amend mode
> > on/off" button. Since "Amend last commit" and "New Commit" are mutually
> > exclusive, a single toggle to switch between those modes makes sense to
> > me.
> 
> I assume you're talking about the button in the "Commit" dropdown

Yes. That one and the two tick boxes on the top right of the commit message buffer/editor.

Show 6 quoted lines
> menu. I agree, it could be just a single entry which is a toggle to
> enable/disable amending. And (above the commit message dialog) perhaps
> just a single checkbox; "Amend Last Commit". In other git GUIs (Git
> Cola and TortoiseGit) I see they're using just a single checkbox for
> this option. But maybe that is a slightly different topic, the hotkey
> behaviour would remain the same.

Yes, of course your patch is independent of the two-button behaviour. I was just pointing it out to see how others feel about it.

Show 8 quoted lines
> 
> 
> > ... do you still feel the need for a dedicated binding for amends?
> 
> How do you guys feel about it? So far it seems we're at two "yay" and
> one "nay". I really feel it is in the best interest of the git-gui
> project to implement this hotkey. And not just because it is my
> personal preference to have it :-)

Well, I do think amending commits is a common enough operation to warrant a dedicated keyboard binding for it. So it is a "yay" for this feature from my side at least.

-- 
Regards,
Pratyush Yadav
David· Sep 3, 2019, 15:35 UTC · re: Pratyush Yadav · lore

Re: feature request, git-gui: add hotkey to toggle amend/new

On Tue, 3 Sep 2019 at 22:45, Pratyush Yadav <me@yadavpratyush.com> wrote:
>
> Can you try doing a Shift+Tab? For me on Linux, if I hit Shift+Tab, it
> immediately takes me to the "Amend last commit" option. Then I can press
> space to select it and Tab again to get back to the commit message.
Hi Pratyush Yadav,

Yes, we know it can be done this way. The point being made is not "this cannot be changed with the keyboard". We know that you can fool around with the tab key and the shift key and the spacebar and eventually you can succeed in changing this option.

And if you want to toggle it back again, you have to do a slightly different keyboard dance, depending on where your cursor or highlight is currently positioned.

Rather what we (at least I) am hoping to communicate is that after you have done this many thousands of times, and you can do everything else in git-gui very fast without touching the mouse, you might also join us in wishing for action to be achievable with one hotkey-combination event that does not affect any other state, it just toggles new/amend commit, and is not a sequence of several multi-key actions which must be adapted according to the current status of other input mode actions.

Pratyush Yadav· Sep 3, 2019, 17:27 UTC · re: David · lore

Re: feature request, git-gui: add hotkey to toggle amend/new

On 04/09/19 01:35AM, David wrote:
Show 12 quoted lines
> On Tue, 3 Sep 2019 at 22:45, Pratyush Yadav <me@yadavpratyush.com> wrote:
> >
> > Can you try doing a Shift+Tab? For me on Linux, if I hit Shift+Tab, it
> > immediately takes me to the "Amend last commit" option. Then I can press
> > space to select it and Tab again to get back to the commit message.
> 
> Hi Pratyush Yadav,
> 
> Yes, we know it can be done this way. The point being made is not
> "this cannot be changed with the keyboard". We know that you can
> fool around with the tab key and the shift key and the spacebar and
> eventually you can succeed in changing this option.

Yes, but what Birger was saying was hitting Ctrl+Tab 9-10 times to get to the option. This is much faster than that alternative.

My aim was to let people know what options already exist before 
proposing new ones.
 
Show 11 quoted lines
> And if you want to toggle it back again, you have to do a slightly
> different keyboard dance, depending on where your cursor or
> highlight is currently positioned.
> 
> Rather what we (at least I) am hoping to communicate is that after you
> have done this many thousands of times, and you can do everything
> else in git-gui very fast without touching the mouse, you might also join
> us in wishing for action to be achievable with one hotkey-combination
> event that does not affect any other state, it just toggles new/amend
> commit, and is not a sequence of several multi-key actions which must
> be adapted according to the current status of other input mode actions.

Don't get me wrong. I am not against having a dedicated hotkey for toggling amends. I think it is a common enough operation to warrant a dedicated keyboard toggle. I was just letting everyone know what the current options are, so they can make better judgements whether they really need this option or not.

-- 
Regards,
Pratyush Yadav
Johannes Sixt· Sep 4, 2019, 06:24 UTC · re: Pratyush Yadav · lore

Re: feature request, git-gui: add hotkey to toggle amend/new

Am 03.09.19 um 14:45 schrieb Pratyush Yadav:
> Can you try doing a Shift+Tab? For me on Linux, if I hit Shift+Tab, it 
> immediately takes me to the "Amend last commit" option. Then I can press 
> space to select it and Tab again to get back to the commit message.
That works on Windows with Ctrl+Shift+Tab, too.
Show 5 quoted lines
> Also, since we are on this topic, how about making the "Amend last 
> commit" button a toggle instead? This would act as a "turn amend mode 
> on/off" button. Since "Amend last commit" and "New Commit" are mutually 
> exclusive, a single toggle to switch between those modes makes sense to 
> me.

That is worth a try. The check box title offers a natural hotkey then: "_A_mend last commit", Alt-a.

-- Hannes
Pratyush Yadav· Sep 4, 2019, 17:46 UTC · re: Johannes Sixt · lore

Re: feature request, git-gui: add hotkey to toggle amend/new

On 04/09/19 08:24AM, Johannes Sixt wrote:
Show 15 quoted lines
> Am 03.09.19 um 14:45 schrieb Pratyush Yadav:
> > Can you try doing a Shift+Tab? For me on Linux, if I hit Shift+Tab, it 
> > immediately takes me to the "Amend last commit" option. Then I can press 
> > space to select it and Tab again to get back to the commit message.
> 
> That works on Windows with Ctrl+Shift+Tab, too.
> 
> > Also, since we are on this topic, how about making the "Amend last 
> > commit" button a toggle instead? This would act as a "turn amend mode 
> > on/off" button. Since "Amend last commit" and "New Commit" are mutually 
> > exclusive, a single toggle to switch between those modes makes sense to 
> > me.
> 
> That is worth a try. The check box title offers a natural hotkey then:
> "_A_mend last commit", Alt-a.

Right now, the binding proposed is Ctrl-e. My mental model for the key bindings as of now is having the "actions" bound to Ctrl, and bindings that move you around in the UI bound to Alt. So it makes more sense to me to have a "amend toggle" bound to Ctrl. Maybe that's just me though. Anyone else care to chime in?

-- 
Regards,
Pratyush Yadav
Birger Skogeng Pedersen· Sep 4, 2019, 17:54 UTC · re: Pratyush Yadav · lore

Re: feature request, git-gui: add hotkey to toggle amend/new

Hi,

You could argue that A (as in "amend") makes quite an intuitive hotkey. But personally I'm also leaning towards CTRL/CMD+E. The ALT+(letter) combination is used to open a menu, for instance ALT+R opens "Repository", ALT+E opens "Edit", etc. That's the behaviour on Windows, anyways. So the hotkeys may seem a bit "mixed up" when ALT+(some letter) opens the corresponding menu but ALT+A does something quite different.

Birger
Johannes Sixt· Sep 4, 2019, 18:52 UTC · re: Pratyush Yadav · lore

Re: feature request, git-gui: add hotkey to toggle amend/new

Am 04.09.19 um 19:46 schrieb Pratyush Yadav:
Show 9 quoted lines
> On 04/09/19 08:24AM, Johannes Sixt wrote:
>> That is worth a try. The check box title offers a natural hotkey then:
>> "_A_mend last commit", Alt-a.
> 
> Right now, the binding proposed is Ctrl-e.  My mental model for the key 
> bindings as of now is having the "actions" bound to Ctrl, and bindings 
> that move you around in the UI bound to Alt.  So it makes more sense to 
> me to have a "amend toggle" bound to Ctrl.  Maybe that's just me though.  
> Anyone else care to chime in?
"Amend last commit" is NOT an action. It switches a state.

It is common in Windows GUIs that every control, including menu items, has a hotkey associated, the underlined letter in the caption, and the hotkey to access that UI control is Alt+that letter. It's not necessarily a matter of moving around.

And, BTW, this hotkey thing is also the case on my Linux desktop (KDE-based).

But of course, git-gui is different and totally off track here. It has *zero* controls marked for hotkey-accessibility. I was just hoping to spark an effort to make some of the controls marked and hotkey-accessible.

-- Hannes
Bert Wesarg· Sep 4, 2019, 19:03 UTC · re: Johannes Sixt · lore

Re: feature request, git-gui: add hotkey to toggle amend/new

On Wed, Sep 4, 2019 at 8:52 PM Johannes Sixt <j6t@kdbg.org> wrote:
Show 25 quoted lines
>
> Am 04.09.19 um 19:46 schrieb Pratyush Yadav:
> > On 04/09/19 08:24AM, Johannes Sixt wrote:
> >> That is worth a try. The check box title offers a natural hotkey then:
> >> "_A_mend last commit", Alt-a.
> >
> > Right now, the binding proposed is Ctrl-e.  My mental model for the key
> > bindings as of now is having the "actions" bound to Ctrl, and bindings
> > that move you around in the UI bound to Alt.  So it makes more sense to
> > me to have a "amend toggle" bound to Ctrl.  Maybe that's just me though.
> > Anyone else care to chime in?
>
> "Amend last commit" is NOT an action. It switches a state.
>
> It is common in Windows GUIs that every control, including menu items,
> has a hotkey associated, the underlined letter in the caption, and the
> hotkey to access that UI control is Alt+that letter. It's not
> necessarily a matter of moving around.
>
> And, BTW, this hotkey thing is also the case on my Linux desktop
> (KDE-based).
>
> But of course, git-gui is different and totally off track here. It has
> *zero* controls marked for hotkey-accessibility. I was just hoping to
> spark an effort to make some of the controls marked and hotkey-accessible.

I'm in favor of making this a checkbox, also in the menu. As all menu entries have currently a CTRL+ binding assigned, I think this one should have one too. As CTRL+A is taken, and the proposal is CTRL+E, I would be fine with this. If the menus and the UX elements also honors mnemonic now or in the future, I don't think they need to match the CTRL+ binding. Thus if this gets Alt+A I'm fine with this too.

Bert
>
> -- Hannes
David Aguilar· Sep 10, 2019, 08:54 UTC · re: Bert Wesarg · lore

Re: feature request, git-gui: add hotkey to toggle amend/new

On Wed, Sep 04, 2019 at 09:03:02PM +0200, Bert Wesarg wrote:
Show 38 quoted lines
> On Wed, Sep 4, 2019 at 8:52 PM Johannes Sixt <j6t@kdbg.org> wrote:
> >
> > Am 04.09.19 um 19:46 schrieb Pratyush Yadav:
> > > On 04/09/19 08:24AM, Johannes Sixt wrote:
> > >> That is worth a try. The check box title offers a natural hotkey then:
> > >> "_A_mend last commit", Alt-a.
> > >
> > > Right now, the binding proposed is Ctrl-e.  My mental model for the key
> > > bindings as of now is having the "actions" bound to Ctrl, and bindings
> > > that move you around in the UI bound to Alt.  So it makes more sense to
> > > me to have a "amend toggle" bound to Ctrl.  Maybe that's just me though.
> > > Anyone else care to chime in?
> >
> > "Amend last commit" is NOT an action. It switches a state.
> >
> > It is common in Windows GUIs that every control, including menu items,
> > has a hotkey associated, the underlined letter in the caption, and the
> > hotkey to access that UI control is Alt+that letter. It's not
> > necessarily a matter of moving around.
> >
> > And, BTW, this hotkey thing is also the case on my Linux desktop
> > (KDE-based).
> >
> > But of course, git-gui is different and totally off track here. It has
> > *zero* controls marked for hotkey-accessibility. I was just hoping to
> > spark an effort to make some of the controls marked and hotkey-accessible.
> 
> I'm in favor of making this a checkbox, also in the menu. As all menu
> entries have currently a CTRL+ binding assigned, I think this one
> should have one too. As CTRL+A is taken, and the proposal is CTRL+E, I
> would be fine with this. If the menus and the UX elements also honors
> mnemonic now or in the future, I don't think they need to match the
> CTRL+ binding. Thus if this gets Alt+A I'm fine with this too.
> 
> Bert
> 
> >
> > -- Hannes

git-gui might not be so focused on providing a fast way to launch a visual $EDITOR, but Ctrl+E is the hotkey we use everywhere in git-cola when lauching external editors on selected files. Sometimes it's the "hot" action so even "Enter" gets that action, but it's worth considering if we ever want git-gui's status widget to be able to launch editors.

We also let Ctrl+Enter launch the default xdg-open action on the selected file (e.g. image files go to the default image editing program, html files to a browser, etc).

While we're on the topic of hotkeys, some valuable hotkeys for an English-centric keyboard are {J,K,L} because of the home row.

In web browsers, Ctrl-L is a very common hotkey for focusing the URL input, so we stole that same hotkey for the "git log <...>" input in the git-dag tool. In that tool the arguments to "log" are very much like a URL from the input perspective, so it's nice to be able to use a familiar and convenient hotkey for that purpose. The placement of the input field[1] is also at the top of that tool, just like in a web browser.

[1] https://git-cola.github.io/images/dag.png

Ctrl-L is also used to focus the "Commit summary" line edit for the main git-cola commit message editor. That seems like the most sensible "main" behavior for the main commit GUI. Maybe git-gui can do that too.

Ctrl-J is kinda like "down" in vim, and so we let that focus the "diff" widget which is typically "down" below the status and commit widgets in cola[2].

[2] https://git-cola.github.io/images/screenshot-dark-linux.png

Ctrl-K focuses the status widget because it's "up". Also, K and L are adjacent on the keyboard, and they are also adjacent visually in the UI so there's a visual and muscle memory pairing there between the Status and Commit widgets.

The JKL hotkeys are nice to have in addition to the numeric hotkeys because they're so convenient. In some cases (like when the diff widget is focused) we allow Alt-{J,K} to jump down/up (next/prev) between the files in the status widget, otherwise regular {J,K} can be used if it has focus.

Thanks for at least trying to keep some parity with git-cola's hotkeys. It's not completely possible in all situations, but it's good to at least share notes on how we use the GUI.

-- 
David
Birger Skogeng Pedersen· Sep 11, 2019, 10:27 UTC · re: David Aguilar · lore

Re: feature request, git-gui: add hotkey to toggle amend/new

Hi Pratyush,

I'm hoping this will be merged, even without changing the radio selectors to a checkbox(?). The patch from Bert resolves the issue I raised about wanting the hotkey. What do you think?

Birger
Pratyush Yadav· Sep 11, 2019, 18:34 UTC · re: Birger Skogeng Pedersen · lore

Re: feature request, git-gui: add hotkey to toggle amend/new

On 11/09/19 12:27PM, Birger Skogeng Pedersen wrote:
Show 6 quoted lines
> Hi Pratyush,
> 
> I'm hoping this will be merged, even without changing the radio
> selectors to a checkbox(?). The patch from Bert resolves the issue I
> raised about wanting the hotkey.
> What do you think?
What do you mean by "this"? I am guessing you mean [0].

I'm afraid that patch conflicts with Bert's change [1] to using a checkbox. Since both patches are in flight, it makes more sense to base your work off his. If I merge your patch now, I'll have to revert it as soon as it is time to merge Bert's, and then rework your patch.

Also, after Bert's patch, the toggling becomes much simpler. All you'd have to do is something like:

  bind . <$M1B-Key-e> {
	# Toggle commit type.
	set commit_type_is_amend [expr {!$commit_type_is_amend}]
	do_select_commit_type
  }

Maybe a cleaner way is possible, but this is what I could come up with for toggling a boolean.

So can you please send a re-roll based on Bert's patch? I took a quick glance at it, and it seems mostly correct. I have a couple of comments, so some things might change based on the discussion, but I don't think it should affect your change too much.

[0] https://public-inbox.org/git/20190904175943.11924-1-birger.sp@gmail.com/ [1] https://public-inbox.org/git/ab1f68cc8552e405c9d04622be1e728ab81bda17.1567713659.git.bert.wesarg@googlemail.com/

-- 
Regards,
Pratyush Yadav
Pratyush Yadav· Sep 11, 2019, 18:47 UTC · re: Pratyush Yadav · lore

Re: feature request, git-gui: add hotkey to toggle amend/new

On 12/09/19 12:04AM, Pratyush Yadav wrote:
Show 23 quoted lines
> On 11/09/19 12:27PM, Birger Skogeng Pedersen wrote:
> > Hi Pratyush,
> > 
> > I'm hoping this will be merged, even without changing the radio
> > selectors to a checkbox(?). The patch from Bert resolves the issue I
> > raised about wanting the hotkey.
> > What do you think?
> 
> What do you mean by "this"? I am guessing you mean [0].
> 
> I'm afraid that patch conflicts with Bert's change [1] to using a 
> checkbox. Since both patches are in flight, it makes more sense to base 
> your work off his. If I merge your patch now, I'll have to revert it as 
> soon as it is time to merge Bert's, and then rework your patch.
> 
> Also, after Bert's patch, the toggling becomes much simpler. All you'd 
> have to do is something like:
> 
>   bind . <$M1B-Key-e> {
> 	# Toggle commit type.
> 	set commit_type_is_amend [expr {!$commit_type_is_amend}]
> 	do_select_commit_type
>   }

I forgot to mention one more thing. You'd also want to mark the menu entry of the amend toggle with Ctrl+e keybinding, like we do for all other bindings (F5 for rescan, Ctrl+T for staging, etc.).

-- 
Regards,
Pratyush Yadav
David· Sep 3, 2019, 01:01 UTC · re: Bert Wesarg · lore

Re: feature request, git-gui: add hotkey to toggle amend/new

On Tue, 3 Sep 2019 at 04:11, Bert Wesarg <bert.wesarg@googlemail.com> wrote:
> On Mon, Sep 2, 2019 at 6:25 PM Birger Skogeng Pedersen <birger.sp@gmail.com> wrote:
> > On Sat, Aug 31, 2019 at 12:51 PM Birger Skogeng Pedersen <birger.sp@gmail.com> wrote:
> > > In my pursuit to fully utilize git-gui with only using a keyboard, I
> > > suggest that there is a hotkey to toggle between selecting "New
> > > Commit" and "Amend Last Commit".

Hi, thanks for maintaining and contributing to git and git-gui, it's a great tool!

> After focusing the commit message widget, you can focus the radio
> buttons with Tab/Shift+Tab and press Space.
> I think this is short enough, so that wasting a Letter is not
> justified here.

Ugh, may I express how unhappy I am to read that opinion from the maintainer. I strongly disagree, please reconsider :(

And I enthusiastically support this initial request for a single hotkey to immediately toggle between "New Commit" and "Amend Last Commit". And it should work regardless of wherever the cursor or highlight is currently active.

I have used git-gui for many years and I find this is actually the most annoying and inconsistent aspect of its user interface. Sometimes if one is lucky then "spacebar" will achieve it at startup or after refresh, sometimes not. When I test here just now the suggested tab/shift-tab/spacebar method, it does toggle but it also changes the items in the staged changes list as an unwanted side effect. My version says 0.20.0.8.gd000, but I have a few local patches (written years ago) so sorry I am not testing with a version that you have, but even so I wanted to report what I observed.

If one is often amending commit messages as I do during large interactive rebases, it is painful to have to do some kind of context-sensitive multi-key dance just to change from "New Commit" to "Amend Last Commit". Especially when every other operation has become a single keystroke in my muscle memory.

In my world it most definitely would not be "wasting a letter" to implement this! It would instead be "OMG at last that got fixed for everyone, hooray!" :D

Bert Wesarg· Sep 3, 2019, 08:44 UTC · re: David · lore

Re: feature request, git-gui: add hotkey to toggle amend/new

David,
On Tue, Sep 3, 2019 at 3:01 AM David <bouncingcats@gmail.com> wrote:
Show 45 quoted lines
>
> On Tue, 3 Sep 2019 at 04:11, Bert Wesarg <bert.wesarg@googlemail.com> wrote:
> > On Mon, Sep 2, 2019 at 6:25 PM Birger Skogeng Pedersen <birger.sp@gmail.com> wrote:
> > > On Sat, Aug 31, 2019 at 12:51 PM Birger Skogeng Pedersen <birger.sp@gmail.com> wrote:
>
> > > > In my pursuit to fully utilize git-gui with only using a keyboard, I
> > > > suggest that there is a hotkey to toggle between selecting "New
> > > > Commit" and "Amend Last Commit".
>
> Hi, thanks for maintaining and contributing to git and git-gui, it's a
> great tool!
>
> > After focusing the commit message widget, you can focus the radio
> > buttons with Tab/Shift+Tab and press Space.
>
> > I think this is short enough, so that wasting a Letter is not
> > justified here.
>
> Ugh, may I express how unhappy I am to read that opinion from
> the maintainer. I strongly disagree, please reconsider :(
>
> And I enthusiastically support this initial request for a single
> hotkey to immediately toggle between "New Commit" and "Amend Last
> Commit". And it should work regardless of wherever the cursor or
> highlight is currently active.
>
> I have used git-gui for many years and I find this is actually the
> most annoying and inconsistent aspect of its user interface. Sometimes
> if one is lucky then "spacebar" will achieve it at startup or after
> refresh, sometimes not. When I test here just now the suggested
> tab/shift-tab/spacebar method, it does toggle but it also changes the
> items in the staged changes list as an unwanted side effect. My
> version says 0.20.0.8.gd000, but I have a few local patches (written
> years ago) so sorry I am not testing with a version that you have, but
> even so I wanted to report what I observed.
>
> If one is often amending commit messages as I do during large
> interactive rebases, it is painful to have to do some kind of
> context-sensitive multi-key dance just to change from "New Commit" to
> "Amend Last Commit". Especially when every other operation has become
> a single keystroke in my muscle memory.
>
> In my world it most definitely would not be "wasting a letter" to
> implement this! It would instead be "OMG at last that got fixed for
> everyone, hooray!" :D
thanks for the input. Though I'm not the maintainer.
Bert

← back to recent threads