Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: add ability to split hunks into smaller hunks #749

Open
OliverJAsh opened this issue Mar 26, 2020 · 6 comments
Open

Suggestion: add ability to split hunks into smaller hunks #749

OliverJAsh opened this issue Mar 26, 2020 · 6 comments
Labels
enhancement New feature or request usability

Comments

@OliverJAsh
Copy link

Is your feature request related to a problem? Please describe.
I like the ability to select hunks, but sometimes the hunks are too big and need to be broken down into smaller hunks. git add --patch provides an option for this—the s shortcut. It would be great if lazygit could provide something similar.

Describe the solution you'd like
When a hunk is selected, pressing s should split it into smaller hunks, like how it works in git add --patch.

Describe alternatives you've considered

Additional context

@OliverJAsh OliverJAsh added the enhancement New feature or request label Mar 26, 2020
@jesseduffield
Copy link
Owner

currently if you hit enter on a file you'll enter line-by-line staging mode where you can stage the file on a per-line basis. In that context, space will stage a line and v allows you to select a range of lines to stage. As for splitting up hunks, I'm not quite sure how I'd go about that. I think the line-by-line approach is pretty solid. What are your thoughts?

@OliverJAsh
Copy link
Author

Here's an example. Say I have these unstaged changes:

image

I only want to stage the first set of changes. Unfortunately Git considers all of the changes as a single hunk, because these changes live so close together. That's where s comes in useful.

I could use the line-by-line approach, but that would be annoying if there were many lines in the change. The change could be hundreds of lines long 🤔

@alok
Copy link

alok commented May 25, 2020

I'm also in favor of this, as it makes feasible mass editing a bunch of changes in a single pass, then going back and committing them separately. Line by line is not convenient there.

@alok
Copy link

alok commented Apr 11, 2021

@jesseduffield thoughts on this?

@jesseduffield
Copy link
Owner

I'm in favour of it, but last time I checked it wasn't straightforward to do. Happy to give pointers if somebody wants to tackle it

@Xevion
Copy link

Xevion commented Dec 27, 2022

Beginner; unfortunately when I press a to select the hunk, it selects the entire file. There are very clear areas of separation between the hunk, yet it selects the entire file. Forced to use v to select my commit somewhat slowly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request usability
Projects
None yet
Development

No branches or pull requests

4 participants