From: Dennis van Gerwen <dvg@xs4all.nl>
To: git@vger.kernel.org
Subject: Feature Request: Custom split location for `git add --patch`
Date: Thu, 16 Jun 2022 12:19:08 +0200 [thread overview]
Message-ID: <da79cc66-42a0-2563-d09b-fbc0ad5b28bd@xs4all.nl> (raw)
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
next reply other threads:[~2022-06-16 10:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-16 10:19 Dennis van Gerwen [this message]
2022-06-18 13:01 ` Feature Request: Custom split location for `git add --patch` Johannes Schindelin
2022-06-21 15:49 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=da79cc66-42a0-2563-d09b-fbc0ad5b28bd@xs4all.nl \
--to=dvg@xs4all.nl \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).