git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Feature Request: Custom split location for `git add --patch`
@ 2022-06-16 10:19 Dennis van Gerwen
  2022-06-18 13:01 ` Johannes Schindelin
  0 siblings, 1 reply; 3+ messages in thread
From: Dennis van Gerwen @ 2022-06-16 10:19 UTC (permalink / raw)
  To: git

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-21 15:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-16 10:19 Feature Request: Custom split location for `git add --patch` Dennis van Gerwen
2022-06-18 13:01 ` Johannes Schindelin
2022-06-21 15:49   ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).