From: Junio C Hamano <gitster@pobox.com>
To: Phillip Wood <phillip.wood123@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/2] rebase: remember fixup -c after skipping fixup/squash
Date: Fri, 24 Jul 2026 14:18:58 -0700 [thread overview]
Message-ID: <xmqqtspo3x31.fsf@gitster.g> (raw)
In-Reply-To: <7c8075ff2675976821a1ee979f86c7c46a35bd15.1784304378.git.phillip.wood@dunelm.org.uk> (Phillip Wood's message of "Fri, 17 Jul 2026 17:06:37 +0100")
Phillip Wood <phillip.wood123@gmail.com> writes:
> return starts_with(ctx->current_fixups.buf, "squash") ||
> strstr(ctx->current_fixups.buf, "\nsquash");
> +}
> +
> +/* Does the current fixup chain contain a "fixup -c" command? */
> +static int seen_fixup_edit_msg(struct replay_ctx *ctx)
> +{
> + return starts_with(ctx->current_fixups.buf, "fixup -c") ||
> + strstr(ctx->current_fixups.buf, "\nfixup -c");
> }
It is a bit annoying that "git diff" decided to consider the "}" at
the end of the otherwise unmodified function to be the one that was
added X-<. But thanks to it, we can see this mirrors the previous
function to check if we have "squash" anywhere. I wonder what
diff-algorithm was used to produce this result, but it is an
unrelated tangent.
It is a bit surprising that we do not carefully parse each line to
identify a 'squash' or a 'fixup -c', which would make it unnecessary
to guess whether the current line is what we are looking for or if
the desired string immediately follows a newline later on. Still,
this patch inherits that pattern from the original code, so it is
not a fault of this change.
> static void update_comment_bufs(struct strbuf *buf1, struct strbuf *buf2, int n)
> @@ -2148,9 +2155,14 @@ static int update_squash_messages(struct repository *r,
> strbuf_release(&buf);
>
> if (!res) {
> - strbuf_addf(&ctx->current_fixups, "%s%s %s",
> + const char *fixup_flag = "";
> +
> + if (is_fixup_flag(command, flag) && (flag & TODO_EDIT_FIXUP_MSG))
> + fixup_flag = " -c";
> +
> + strbuf_addf(&ctx->current_fixups, "%s%s%s %s",
> ctx->current_fixups.len ? "\n" : "",
> - command_to_string(command),
> + command_to_string(command), fixup_flag,
> oid_to_hex(&commit->object.oid));
> res = write_message(ctx->current_fixups.buf,
> ctx->current_fixups.len,
> @@ -5391,8 +5403,8 @@ static int commit_staged_changes(struct repository *r,
> * message, no need to bother the user with
> * opening the commit message in the editor.
> */
> - if (!starts_with(p, "squash ") &&
> - !strstr(p, "\nsquash "))
> + if (!seen_squash(ctx) &&
> + !seen_fixup_edit_msg(ctx))
> flags = (flags & ~EDIT_MSG) | CLEANUP_MSG;
If 'fixup -c' is anywhere in the chain, we would need to offer the
user a chance to edit (similar to having 'squash').
It is a bit surprising that the 'squash' detection, for which we
already had a helper function, was open-coded here. I also notice
that the helpers (including the new 'fixup -c' one) do not insist on
having a space immediately after the verb 'squash'. Should we add
one above?
Other than these minor nits, this looks good.
It is a bit disappointing that, with so many users who crucially
depend on the proper operation of 'rebase -i', we have received no
review comments on these two patches so far. Perhaps summer is a
truly quiet and slow season ;-)
I will wait for a few more days and then mark the topic for 'next'.
Thanks.
next prev parent reply other threads:[~2026-07-24 21:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-17 16:06 [PATCH 0/2] rebase: a couple of fixup fixes Phillip Wood
2026-07-17 16:06 ` [PATCH 1/2] rebase -i: fix counting of fixups after rebase --skip Phillip Wood
2026-07-24 21:01 ` Junio C Hamano
2026-07-17 16:06 ` [PATCH 2/2] rebase: remember fixup -c after skipping fixup/squash Phillip Wood
2026-07-24 21:18 ` Junio C Hamano [this message]
2026-07-26 15:41 ` Phillip Wood
2026-07-26 21:32 ` Junio C Hamano
2026-07-26 15:38 ` [PATCH v2 0/2] rebase: a couple of fixup fixes Phillip Wood
2026-07-26 15:38 ` [PATCH v2 1/2] rebase -i: fix counting of fixups after rebase --skip Phillip Wood
2026-07-26 15:39 ` [PATCH v2 2/2] rebase: remember fixup -c after skipping fixup/squash 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=xmqqtspo3x31.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--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