public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Luiz Campos <luizedc1@gmail.com>
To: git@vger.kernel.org
Cc: luizedc1@gmail.com, peff@peff.net, sagotsky@gmail.com,
	Johannes.Schindelin@gmx.de
Subject: [RFC PATCH 0/1] add -p: support discarding hunks
Date: Wed, 25 Mar 2026 04:50:54 -0300	[thread overview]
Message-ID: <20260325075055.354709-1-luizedc1@gmail.com> (raw)

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%2BLZXs@coredump.intra.peff.net/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(-)

-- 
2.43.0


             reply	other threads:[~2026-03-25  7:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-25  7:50 Luiz Campos [this message]
2026-03-25  7:50 ` [RFC PATCH 1/1] add -p: support discarding hunks with 'x' Luiz Campos
2026-03-25 15:44   ` D. Ben Knoble
2026-03-25 17:04     ` Luiz Eduardo Campos
2026-03-25 16:24   ` Phillip Wood
2026-03-25 18:38     ` Luiz Eduardo Campos
2026-03-25 16:49   ` Johannes Schindelin
2026-03-25 18:58     ` Luiz Eduardo Campos
2026-03-25 18:03 ` [RFC PATCH 0/1] add -p: support discarding hunks Junio C Hamano
2026-03-25 19:22   ` Luiz Eduardo Campos

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260325075055.354709-1-luizedc1@gmail.com \
    --to=luizedc1@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    --cc=sagotsky@gmail.com \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox