From: Junio C Hamano <gitster@pobox.com>
To: Phillip Wood <phillip.wood123@gmail.com>
Cc: git@vger.kernel.org, Elijah Newren <newren@gmail.com>
Subject: Re: [PATCH] replay: drop commits that become empty
Date: Thu, 27 Nov 2025 23:29:22 -0800 [thread overview]
Message-ID: <xmqqbjkmk431.fsf@gitster.g> (raw)
In-Reply-To: <8a2a1215306452147cc7b803530ab2429bf57f15.1764260150.git.phillip.wood@dunelm.org.uk> (Phillip Wood's message of "Thu, 27 Nov 2025 16:15:54 +0000")
Phillip Wood <phillip.wood123@gmail.com> writes:
> From: Phillip Wood <phillip.wood@dunelm.org.uk>
>
> If the changes in a commit being replayed are already in the branch
> that the commits are being replayed onto then "git replay" creates an
> empty commit. This is confusing because the commit message no longer
> matches the contents of the commit. Drop the commit instead.
If a commit that originally did two or more things is replayed on a
destination that already has only part of it, then the extent of the
change the replayed commit makes will shrink, and the commit message
no longer matches it, either. It is a lot harder to notice the
situation to prompt the user to rewrite the resulting commit
message, but in the degenerated case where the entire changes go
away, the rewrite of the resulting commit message is very simple,
which is to remove the commit altogether.
Makes sense.
> Commits
> that start off empty are not dropped.
Makes perfect sense, too.
> This matches the behavior of
> "git rebase --reapply-cherry-pick --empty=drop" and "git cherry-pick
> --empty-drop". If a branch points to a commit that is dropped it will
> be updated to point to the last commit that was not dropped. This can
> been seen in the new test where "topic1" is updated to point to the
> rebased "C" as "F" is dropped because it is already upstream. While
> this is a breaking change "git replay" is marked as experimental to
> allow improvements like this that change the behavior.
>
> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
> ---
> Elijah - I'm not really clear why we were setting result->tree before
> calling merge_incore_nonrecursive(), was it just for convenience to
> avoid declaring a local variable or have I missed something?
>
> This patch is based on ps/history
As I take this more as a rfc/rfh than finalized version, it is OK to
depend on the topic that is known to be rerolled soonish.
> I think dropping commits that become empty is the sensible default,
> if it turns out that some users are relying on the current behavior
> we can add an option to retain the empty commits.
I think it would be a good default to drop what becomes empty.
next prev parent reply other threads:[~2025-11-28 7:29 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-27 16:15 [PATCH] replay: drop commits that become empty Phillip Wood
2025-11-28 7:29 ` Junio C Hamano [this message]
2025-12-04 14:08 ` Phillip Wood
2025-11-28 8:06 ` Elijah Newren
2025-12-04 14:06 ` Phillip Wood
2025-12-15 10:07 ` [PATCH v2] " Phillip Wood
2025-12-15 23:50 ` Junio C Hamano
2025-12-16 14:19 ` Phillip Wood
2025-12-17 14:45 ` Phillip Wood
2025-12-17 23:49 ` Junio C Hamano
2025-12-16 0:21 ` Elijah Newren
2025-12-16 14:19 ` [PATCH v3] " Phillip Wood
2025-12-16 16:36 ` Elijah Newren
2025-12-17 14:47 ` Phillip Wood
2025-12-18 16:50 ` [PATCH v4] " Phillip Wood
2025-12-19 4:44 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqbjkmk431.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=newren@gmail.com \
--cc=phillip.wood123@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;
as well as URLs for NNTP newsgroup(s).