git: Add partial committing - #55179
Conversation
|
Apologies for the size of this PR. Many of the changes are closely connected. Happy to pair/walk through it. |
5de6541 to
98d53a9
Compare
|
Thanks for working on this! I just have one comment: Instead of having to memorize yet another keybinding depending on context I think it would make sense to base the behaviour on whether there is a selection: if there is one then the existing keybinding only stages the selection, and if there isn't then it stages the current hunk just as before. This should also obviate the need for a drop-down menu on the Stage button. That would feel a lot more natural to me. |
|
why isn't this PR merged? |
5866b7b to
bb1ef4d
Compare
|
Is this feature abandoned? |
|
Please implement it!
Paolo Benvenuto
Il gio 2 lug 2026, 15:23 reisub ***@***.***> ha scritto:
… *re1sub* left a comment (zed-industries/zed#55179)
<#55179 (comment)>
Is this feature abandoned?
—
Reply to this email directly, view it on GitHub
<#55179?email_source=notifications&email_token=AAK2CJGB4CR4ELPFZ4BMFED5CZO3JA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIOBWGYYTSMZWGA3KM4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-4866193606>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAK2CJF4OIG5ZF3V6UM6FFD5CZO3JAVCNFSNUABFKJSXA33TNF2G64TZHMZTIMBVGQ3TKMRQHNEXG43VMU5TIMZUHE2TKNBVHE22C5QC>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
|
I am close to finishing this, just busy. |
|
Thank you
don Paolo Benvenuto
Il gio 2 lug 2026, 17:32 AidanV ***@***.***> ha scritto:
… *AidanV* left a comment (zed-industries/zed#55179)
<#55179 (comment)>
I am close to finishing this, just busy.
—
Reply to this email directly, view it on GitHub
<#55179?email_source=notifications&email_token=AAK2CJFBG7WRD74TLILIOGD5CZ6BZA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIOBWG42DOMRYGY32M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-4867472867>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAK2CJDBEYUAOXXKLA367RL5CZ6BZAVCNFSNUABFKJSXA33TNF2G64TZHMZTIMBVGQ3TKMRQHNEXG43VMU5TIMZUHE2TKNBVHE22C5QC>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
|
@janlarres I took your advice and got rid of the other keybinding by doing partial staging if there is a selection. However, I think getting this behavior to be always intuitive is a little tricky, and I am curious to hear what you and others think. The main point of contention is figuring out when deletions that are collapsed should be staged. The behavior that I went with is that if the selection goes across the top of the hunk, then the deletions should be staged. I think this behavior is okay but not perfect, as it is not super obvious to the user that they did not stage the whole hunk if they select all of the lines (see video below). I think this could be resolved with a visual change to the gutter so it doesn't look fully staged when collapsed (but is that enough? And what should that look like, I included a sketch below). Another, imperfect workaround is staging the deleted lines whenever all visible lines of a hunk are selected (but what if a user stages the first half, realizes they have only staged the first half, and then stages the second half? We end up back where we started: the hunk looks fully staged but isn't. Or what if they want to only stage the added lines, then staging the deleted lines is unexpected behavior). I kept the drop-down. I like still being able to stage a specific hunk regardless of the current state of my cursor, and there should be a way for the user to partial stage without using a keybinding. Current behavior: recording_20260705_22-42-15.mp4 |
|
@AidanV That's an interesting question. Intuitively I would think that selecting all of the lines in a hunk should work the same as staging the hunk as a whole, but you're right that that leads to ambiguity if someone stages a hunk piecemeal. I'm currently mostly using LazyGit, which doesn't have this issue because modified lines are never collapsed but shown as individual added and deleted lines. LazyGit also has separate "hunk" and "line" modes instead of allowing selection of lines, and depending on the mode If the above idea is not feasible then a differently-coloured gutter like you described would at least make the ambiguities more obvious. It would even be helpful together with the above idea for when you switch back to "hunk" mode. |
|
#46541 Is quite the merge conflict unfortunately. However, this is a complimentary change and should make this feature better in the long run. I am currently working through the necessary rewrite. |
53d3698 to
c9d4a32
Compare
|
I finished resolving the merge conflict, and I removed the new keybinding and the drop-down UI feature. This means that after this PR lands the only way of interacting with this feature will be through dispatching the Additionally, this feature is not yet implemented on the new 'view unstaged/staged' multibuffers. I am calling it out of scope, and it should be an easy follow up PR. |
|
@AidanV you should add this to context menu as well like vs code right click "stage selected lines" and "unstage selected lines" |
This was a bug in the integration test that was uncovered by correcting the logic for `OverlapsWithSecondaryHunk` and `HasSecondaryHunk`. Previously, partially staged deletions were incorrectly treated as `HasSecondaryHunk`. The correction for partially staged deletions to display as `OverlapsWithSecondaryHunk` is required for partial staging. In this specific test, "TWO"'s deletion is staged, but "two"'s addition is not staged leading to this edge case triggering.

Self-Review Checklist:
Closes #45295
Release Notes:
Adds action for staging/unstaging selected lines
ToggleStagedSelectedLinesAdds keybind to Windows for staging/unstaging hunks
ctrl-alt-y. I am not sure why this wasn't already set. I do not have a windows machine, so I would appreciate some confirmation on this.This PR does not make any UX decisions for how this feature will be used besides providing an action for it. This just provides the infrastructure to be able to make the correct UX decision in a follow up PR.
Known limitation: Identical lines without staging additional surrounding context can cause the line not under the cursor to be staged. This is fixable, but I think that that should be its own PR.
recording_20260429_14-44-05.mp4