L.S.
Please consider this feature request for interactive staging in patch
mode, using [`git add --patch`][1].
## Problem
If a hunk cannot be split automatically, the `s` (split) option
disappears from the list of options, and we get:
> (1/6) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]? s
> Sorry, cannot split this hunk
See for example these questions on StackOverflow: [2], [3]
I am aware that this problem can be solved by using the [`--edit`
option][4] to edit the hunk, as explained in the docs under [editing
patches][5].
However, if we have a large contiguous hunk, and we only want to split
at one specific location, using `--edit` can be quite cumbersome,
because (as far as I know) we need to edit all the lines that we do not
want to stage.
## Feature request
Would it be possible to add a "custom split location" feature, allowing
the user to specify where a contiguous hunk should be split?
Some options:
- Always show the `s` (split hunk) option, and let the user specify a
line number if an automatic split cannot be made.
- Add a new [patch option][6], in addition to `s` (split hunk), to split
any hunk at a custom location.
- Add a new operation for editing patches, for example "s" (in addition
to "+", "-", and " "), indicating where to split (e.g. "split after this
line"). This way the user only needs to modify a single line in edit mode.
I'm sure there are a lot of nasty details to consider, but I do think
such a feature would be very convenient.
Thanks for your help,
Dennis
[1]: https://git-scm.com/docs/git-add#Documentation/git-add.txt---patch
[2]: https://stackoverflow.com/q/6276752
[3]: https://stackoverflow.com/q/56892981
[4]: https://git-scm.com/docs/git-add#Documentation/git-add.txt---edit
[5]: https://git-scm.com/docs/git-add#_editing_patches
[6]: https://git-scm.com/docs/git-add#Documentation/git-add.txt-patch