Skip to content

RFC add -p: support discarding hunks

Luiz Campos git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest1 patch 8 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/1add -p: support discarding hunks with 'x'Documentation/git-add.adoc add-patch.c t/t3701-add-interactive.sh+149 -536 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/1] add -p: support discarding hunks

Hi,

This is an RFC for adding a 'discard hunk' action to git add -p.

Currently, when using git add -p, users can stage or skip hunks, but cannot discard unwanted changes directly from the working tree. This often leads to repeatedly skipping the same hunks across multiple passes.

This patch introduces a new 'x' action to discard the current hunk by reverse-applying it to the working tree.

This idea was previously discussed on the mailing list:
https://lore.kernel.org/git/X%2FiFCo0bXLR%[email protected]/t/#m0576e6f3c6375e11cc4693b9dca3c1fc57baadd0

Open questions:
- Should discard happen immediately or be deferred until patch application?
- Are there edge cases involving overlapping hunks or edited hunks?

Feedback is very welcome.

Thanks,
Luiz

Luiz Campos (1):
[RFC PATCH 0/1] add -p: support discarding hunks with 'x'

 Documentation/git-add.adoc |   7 +-
 add-patch.c                | 137 ++++++++++++++++++++++++++++---------
 t/t3701-add-interactive.sh |  58 ++++++++++------
 3 files changed, 149 insertions(+), 53 deletions(-)
Signature · 1 line
2.43.0