Keyboard shortcut to commit current hunk, or currently selected lines?

32 views
Skip to first unread message

Martin Dengler

unread,
Sep 22, 2014, 10:02:53 AM9/22/14
to gitext...@googlegroups.com
One feature I miss is "stage current hunk [diff] and commit" from git-gutter+[1].  This allows you to stream small changes (think documentation, typos, minor enhancements) in the midst of a larger development session without having to manualy manage the index or stashes or branches.

This feature, if accessible from a keystroke or context menu, would allow this story/use case:

1. work on large change
2. notice small, unrelated change possibility during reading code
3. make change
4. Invoke keyboard shortcut or context menu entry to stage & commit
5. enter commit message & commit
6. goto #1

Normally, even with "git add -i" available and used frequently, I find that what happens without this shortcut was:

1. work on large change
2. notice small, unrelated change possibility during reading code
3. write it down for later, or promise to remember it later
4. never re-read note, or forget
5. goto #1

Would a patch for this be accepted, or is it possible already?


Arkady Shapkin

unread,
Sep 22, 2014, 12:47:42 PM9/22/14
to gitext...@googlegroups.com
Hi

Select lines in Commit window and press "s".

понедельник, 22 сентября 2014 г., 18:02:53 UTC+4 пользователь Martin Dengler написал:

Oliver Friedrich

unread,
Sep 22, 2014, 2:08:08 PM9/22/14
to gitext...@googlegroups.com
Yeah, a great feature, I use it all the time :-D

You can even just put your cursor into the line if it's a single-line change and press "s".

--
Oliver Friedrich
My professional blog: shades-of-orange.com

--
You received this message because you are subscribed to the Google Groups "GitExtensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gitextension...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Martin Dengler

unread,
Sep 23, 2014, 11:05:08 AM9/23/14
to gitext...@googlegroups.com
Hi,

Thanks, but pressing any keys or using the mouse for anything more than the commit message itself is exactly what I want to avoid.  So when you say "in the commit window", it means navigation all over the place to get back to pointing at the to-be-committed hunk I was already editing.  In your example I need to:

1. work on large change
2. notice small, unrelated change possibility during reading code
3. make change using keyboard
4a. move my hands to the mouse
4b. point to GIT -> Commit
4c. scroll/click to select the currently-being-edited file in the "Working dir changes" list
4d. scroll/click to find the hunk I was editing
4e. type 's' to stage
4f. click/tab to move the focus to the commit message input control
5. enter commit message & commit
6. goto #1

Instead, in my proposal, I eliminate 4b-4e:

1. work on large change
2. notice small, unrelated change possibility during reading code
3. make change using keyboard
4a. press magic keystroke to invoke stage-and-commit-current-hunk and put focus in commit message input control
5. enter commit message & commit
6. goto #1

When one has many files changed in one's working copy (situation #1 and plenty of others my users tend to prefer), the step:

4c. scroll/click to select the currently-being-edited file in the "Working dir changes" list

...is not at all trivial and can be the same amount or more of work than noticing and making the small change itself.

Janusz Białobrzewski

unread,
Sep 24, 2014, 3:04:26 AM9/24/14
to gitext...@googlegroups.com
>> Would a patch for this be accepted, or is it possible already?

Yes, we'll accept such a patch.

Martin Dengler

unread,
Sep 25, 2014, 9:00:52 AM9/25/14
to gitext...@googlegroups.com
On Wednesday, September 24, 2014 8:04:26 AM UTC+1, Janusz Białobrzewski wrote:
>> Would a patch for this be accepted, or is it possible already?

Yes, we'll accept such a patch.

Thanks -- I will start on it by opening as issue as CONTRIBUTING.md requests.
 
Reply all
Reply to author
Forward
0 new messages