From: Phillip Wood <phillip.wood123@gmail.com>
To: git@vger.kernel.org
Cc: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
"Junio C Hamano" <gitster@pobox.com>,
"Oswald Buddenhagen" <oswald.buddenhagen@gmx.de>,
"Farid Zakaria" <farid.m.zakaria@gmail.com>,
"Andrei Rybak" <rybak.a.v@gmail.com>,
"Phillip Wood" <phillip.wood123@gmail.com>
Subject: [PATCH v3 0/9] sequencer: do not record dropped commits as rewritten
Date: Wed, 15 Jul 2026 16:21:54 +0100 [thread overview]
Message-ID: <cover.1784128921.git.phillip.wood@dunelm.org.uk> (raw)
In-Reply-To: <cover.1782833268.git.phillip.wood@dunelm.org.uk>
Thanks to everyone who commented on v2. I've dropped patch 2 which
Andrei pointed out was pointless and tried to make the remaining
commit messages clearer as requested by Oswald.
If a commit gets dropped because its changes are already upstream
then we should not record it as rewritten. As well as confusing any
post-rewrite hooks this means we end up copying the notes from the
dropped commit to the commit that was picked immediately before the
one that was dropped.
This series is structured as follows:
Patch 1 restores some test coverage that was lost when the default
rebase backend was changed.
Patches 2 & 3 fix the return value of do_pick_commit() when an external
command fails (this is in preparation for patch 8).
Patches 4-7 try and simplify the control flow in pick_one_commit()
in preparation for patch 8.
Patch 8 changes the return type of do_pick_commit() to an enum.
Patch 9 adds a new member to the enum from patch 8 for commits that
are dropped when they become empty and uses that to stop them from
being recorded as rewritten.
Cover letter for v2:
Thanks to everyone who commented on v1. I've squashed the fixups that
Junio had in "seen", squashed patches 8 & 9 together as suggested by
Oswald and expanded the commit message, and added Uwe's Tested-by:
trailer to the final patch. Oswald suggested extended the use of the
enum which I think is a good idea in the long-term but I punted on
that for now because I think it would be fairly invasive and this
series has enough refactoring in it already.
base-commit: 6c3d7b73556db708feb3b16232fab1efc4353428
Published-As: https://github.com/phillipwood/git/releases/tag/pw%2Frebase-drop-notes-with-commit%2Fv3
View-Changes-At: https://github.com/phillipwood/git/compare/6c3d7b735...2ef36b9ee
Fetch-It-Via: git fetch https://github.com/phillipwood/git pw/rebase-drop-notes-with-commit/v3
Phillip Wood (9):
t3400: restore coverage for note copying with apply backend
sequencer: be more careful with external merge
sequencer: never reschedule on failed commit
sequencer: remove unnecessary "or" in pick_one_commit()
sequencer: simplify handling of fixup with conflicts
sequencer: remove unnecessary condition in pick_one_commit()
sequencer: simplify pick_one_commit()
sequencer: use an enum to represent result of picking a commit
sequencer: do not record dropped commits as rewritten
sequencer.c | 124 +++++++++++++++++++++++++---------
t/t3400-rebase.sh | 16 ++++-
t/t3404-rebase-interactive.sh | 11 +++
t/t5407-post-rewrite-hook.sh | 23 +++++++
4 files changed, 140 insertions(+), 34 deletions(-)
Range-diff against v2:
1: 65af2ac07a2 ! 1: c4705066ee0 t3400: restore coverage for note copying with apply backend
@@ Metadata
## Commit message ##
t3400: restore coverage for note copying with apply backend
- Now that the merge backend is the default we have lost coverage for
+ Now that the merge backend is the default, we have lost coverage for
"git rebase --apply" copying notes. Fix this by replacing "-m" with
"--apply" as the previous test which uses the default backend now
checks the merge backend.
2: 02670f57e7d < -: ----------- sequencer: move definition of is_final_fixup()
3: 3d79362332c ! 2: 947bb77e44f sequencer: be more careful with external merge
@@ Commit message
If an external merge strategy cannot merge (for example because it
would overwrite an untracked file) it exits with a non-zero exit
- code other than 1. This should be treated differently to a merge
- with conflicts which is signalled by an exit code of 1 because as
- the merge failed we need to reschedule the last pick. The caller
+ code other than 1. This should be treated differently from a merge
+ with conflicts, which is signaled by an exit code of 1, because, as
+ the merge failed, we need to reschedule the last pick. The caller
expects us to return -1 in this case. Also reschedule without trying
to merge if the commit message cannot be written as that prevents us
from successfully picking the commit.
4: fc89e77c6e8 = 3: bff5f319e91 sequencer: never reschedule on failed commit
5: 26eef6c0958 = 4: e785433ad3d sequencer: remove unnecessary "or" in pick_one_commit()
6: 26dc48951ce ! 5: 134d8f7e935 sequencer: simplify handing of fixup with conflicts
@@ Metadata
Author: Phillip Wood <phillip.wood@dunelm.org.uk>
## Commit message ##
- sequencer: simplify handing of fixup with conflicts
+ sequencer: simplify handling of fixup with conflicts
Commit e032abd5a0 (rebase: fix rewritten list for failed pick,
- 2023-09-06) introduced an early return when res == -1, so if we enter
- this conditional block then res is positive. After the last couple
- of commits the only possible positive value is 1 so we can simplify
- the code by removing the conditional call to intend_to_amend() and
- call it error_with_patch() instead.
+ 2023-09-06) introduced an early return when res == -1, so if
+ we enter this conditional block then res is positive. After the
+ last couple of commits the only possible positive value is 1. That
+ means we can simplify the code by removing the conditional call to
+ intend_to_amend() and have error_failed_squash() request that it is
+ called in error_with_patch() instead.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
7: 71ed717d322 = 6: e3091dee633 sequencer: remove unnecessary condition in pick_one_commit()
8: e8b7fa4c59e ! 7: 7c1642b0a49 sequencer: simplify pick_one_commit()
@@ Metadata
## Commit message ##
sequencer: simplify pick_one_commit()
- Unless we're rebasing all we do in pick_one_commit() is call
+ Unless we're rebasing, all we do in pick_one_commit() is call
do_pick_commit() and return its result. Simplify the code by returning
- early if we're not rebasing so that we don't have to continually call
+ early if we're not rebasing so that we don't have to repeatedly call
is_rebase_i() in the rest of the function. Note that there are a couple
of conditions that do not call is_rebase_i() but they check for either
an "edit" or a "fixup" command, both of which imply we're rebasing.
The only block that does not return early is the one guarded by
"!res". Move the return into that block to make it clear that after
- recording the commit as rewritten all we do is return from the function.
+ recording the commit as rewritten, all we do is return from the
+ function.
As the conditional blocks are all mutually exclusive (either the
conditions are mutually exclusive, or an earlier conditional block
9: 4fb641afb3c ! 8: 0a146d57266 sequencer: use an enum to represent result of picking a commit
@@ Metadata
## Commit message ##
sequencer: use an enum to represent result of picking a commit
- Rather than using an integer where -1 is an error, 0 is success and
- 1 means there were conflicts use an enum. This is clearer and lets
+ Rather than using an integer where -1 is an error, 0 is success and 1
+ indicates there were conflicts, use an enum. This is clearer and lets
us add a separate return value for commits that are dropped because
they become empty in the next commit.
10: c89234dd949 ! 9: 2ef36b9ee5a sequencer: do not record dropped commits as rewritten
@@ Commit message
If a commit gets dropped because its changes are already upstream
then we should not record it as rewritten. As well as confusing any
- post-rewrite hooks this means we end up copying the notes from the
+ post-rewrite hooks, it means we end up copying the notes from the
dropped commit to the commit that was picked immediately before the
one that was dropped.
- While we do not want to record the dropped commit is rewritten, if
+ While we do not want to record the dropped commit as rewritten, if
it is the final commit in a chain of fixups then we need to flush
the list of rewritten commits. The behavior of an "edit" command
where the commit is dropped is changed so that "rebase --continue"
--
2.54.0.200.gfd8d68259e3
next prev parent reply other threads:[~2026-07-15 15:22 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-16 17:40 [PATCH] sequencer: Skip copying notes for commits that disappear during rebase Uwe Kleine-König
2026-06-17 13:24 ` Junio C Hamano
2026-06-17 13:58 ` Uwe Kleine-König
2026-06-19 10:13 ` Phillip Wood
2026-06-19 13:01 ` Uwe Kleine-König
2026-06-30 15:28 ` [PATCH 00/11] sequencer: do not record dropped commits as rewritten Phillip Wood
2026-06-30 15:28 ` [PATCH 01/11] t3400: restore coverage for note copying with apply backend Phillip Wood
2026-06-30 15:28 ` [PATCH 02/11] sequencer: move definition of is_final_fixup() Phillip Wood
2026-06-30 15:28 ` [PATCH 03/11] sequencer: be more careful with external merge Phillip Wood
2026-06-30 15:28 ` [PATCH 04/11] sequencer: never reschedule on failed commit Phillip Wood
2026-06-30 15:28 ` [PATCH 05/11] sequencer: remove unnecessary "or" in pick_one_commit() Phillip Wood
2026-06-30 15:28 ` [PATCH 06/11] sequencer: simplify handing of fixup with conflicts Phillip Wood
2026-06-30 15:28 ` [PATCH 07/11] sequencer: remove unnecessary condition in pick_one_commit() Phillip Wood
2026-06-30 15:28 ` [PATCH 08/11] sequencer: simplify pick_one_commit() Phillip Wood
2026-07-06 11:06 ` Oswald Buddenhagen
2026-07-06 13:40 ` Phillip Wood
2026-06-30 15:28 ` [PATCH 09/11] sequencer: return early from pick_one_commit() on success Phillip Wood
2026-07-06 11:08 ` Oswald Buddenhagen
2026-06-30 15:29 ` [PATCH 10/11] sequencer: use an enum to represent result of picking a commit Phillip Wood
2026-07-06 11:12 ` Oswald Buddenhagen
2026-07-06 13:39 ` Phillip Wood
2026-06-30 15:29 ` [PATCH 11/11] sequencer: do not record dropped commits as rewritten Phillip Wood
2026-06-30 19:57 ` [PATCH 00/11] " Junio C Hamano
2026-07-01 6:00 ` Uwe Kleine-König
2026-07-01 13:29 ` Phillip Wood
2026-07-01 13:31 ` Phillip Wood
2026-07-13 0:06 ` Junio C Hamano
2026-07-01 9:38 ` Uwe Kleine-König
2026-07-01 13:37 ` Phillip Wood
2026-07-13 13:17 ` [PATCH v2 00/10] " Phillip Wood
2026-07-13 13:17 ` [PATCH v2 01/10] t3400: restore coverage for note copying with apply backend Phillip Wood
2026-07-13 13:43 ` Oswald Buddenhagen
2026-07-13 13:17 ` [PATCH v2 02/10] sequencer: move definition of is_final_fixup() Phillip Wood
2026-07-14 22:50 ` Andrei Rybak
2026-07-15 9:12 ` Phillip Wood
2026-07-13 13:17 ` [PATCH v2 03/10] sequencer: be more careful with external merge Phillip Wood
2026-07-13 14:01 ` Oswald Buddenhagen
2026-07-15 9:35 ` Phillip Wood
2026-07-15 9:42 ` Phillip Wood
2026-07-15 18:53 ` Junio C Hamano
2026-07-13 13:17 ` [PATCH v2 04/10] sequencer: never reschedule on failed commit Phillip Wood
2026-07-13 13:17 ` [PATCH v2 05/10] sequencer: remove unnecessary "or" in pick_one_commit() Phillip Wood
2026-07-13 13:17 ` [PATCH v2 06/10] sequencer: simplify handing of fixup with conflicts Phillip Wood
2026-07-13 14:09 ` Oswald Buddenhagen
2026-07-15 9:20 ` Phillip Wood
2026-07-13 13:17 ` [PATCH v2 07/10] sequencer: remove unnecessary condition in pick_one_commit() Phillip Wood
2026-07-13 13:17 ` [PATCH v2 08/10] sequencer: simplify pick_one_commit() Phillip Wood
2026-07-13 13:17 ` [PATCH v2 09/10] sequencer: use an enum to represent result of picking a commit Phillip Wood
2026-07-13 13:17 ` [PATCH v2 10/10] sequencer: do not record dropped commits as rewritten Phillip Wood
2026-07-13 17:00 ` [PATCH v2 00/10] " Junio C Hamano
2026-07-15 15:21 ` Phillip Wood [this message]
2026-07-15 15:21 ` [PATCH v3 1/9] t3400: restore coverage for note copying with apply backend Phillip Wood
2026-07-15 15:21 ` [PATCH v3 2/9] sequencer: be more careful with external merge Phillip Wood
2026-07-15 15:21 ` [PATCH v3 3/9] sequencer: never reschedule on failed commit Phillip Wood
2026-07-15 15:21 ` [PATCH v3 4/9] sequencer: remove unnecessary "or" in pick_one_commit() Phillip Wood
2026-07-15 15:21 ` [PATCH v3 5/9] sequencer: simplify handling of fixup with conflicts Phillip Wood
2026-07-15 15:22 ` [PATCH v3 6/9] sequencer: remove unnecessary condition in pick_one_commit() Phillip Wood
2026-07-15 15:22 ` [PATCH v3 7/9] sequencer: simplify pick_one_commit() Phillip Wood
2026-07-15 15:22 ` [PATCH v3 8/9] sequencer: use an enum to represent result of picking a commit Phillip Wood
2026-07-15 15:22 ` [PATCH v3 9/9] sequencer: do not record dropped commits as rewritten Phillip Wood
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=cover.1784128921.git.phillip.wood@dunelm.org.uk \
--to=phillip.wood123@gmail.com \
--cc=farid.m.zakaria@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=oswald.buddenhagen@gmx.de \
--cc=phillip.wood@dunelm.org.uk \
--cc=rybak.a.v@gmail.com \
--cc=u.kleine-koenig@baylibre.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