From: Junio C Hamano <gitster@pobox.com>
To: Phillip Wood <phillip.wood123@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/2] rebase -i: fix counting of fixups after rebase --skip
Date: Fri, 24 Jul 2026 14:01:18 -0700 [thread overview]
Message-ID: <xmqqbjbw5cgx.fsf@gitster.g> (raw)
In-Reply-To: <c37a518486a8fa9832a6dbbe6048cda70af87d73.1784304378.git.phillip.wood@dunelm.org.uk> (Phillip Wood's message of "Fri, 17 Jul 2026 17:06:36 +0100")
Phillip Wood <phillip.wood123@gmail.com> writes:
> @@ -3281,7 +3281,13 @@ static int read_populate_opts(struct replay_opts *opts)
> const char *p = ctx->current_fixups.buf;
> ctx->current_fixup_count = 1;
> while ((p = strchr(p, '\n'))) {
> - ctx->current_fixup_count++;
> + /*
> + * Older versions of git accidentally
> + * inserted blank lines when a fixup
> + * was skipped.
> + */
> + if (p[1] != '\n')
> + ctx->current_fixup_count++;
> p++;
> }
> }
If we hit the LF at the very end (e.g. "fixup A\n" at the end of the
file), strchr() would have moved p to the newline, and p[1] will be
'\0', no? And because p[1] != '\n' and wouldn't current_fixup_count
be incremented again? It might be safer to check p[1] != '\n' &&
p[1] != '\0' to avoid counting a trailing newline as an extra
command when reading legacy files.
> @@ -5353,6 +5359,9 @@ static int commit_staged_changes(struct repository *r,
> if (!len)
> BUG("Incorrect current_fixups:\n%s", p);
> while (len && p[len - 1] != '\n')
> + len--;
> + /* Remove trailing newline */
> + if (len)
> len--;
So we removed all the non newline from the end, and the loop would
break if !len or p[len - 1] == '\n'. And in the latter case, we
also drop that '\n'. Which sounds right.
Thanks.
next prev parent reply other threads:[~2026-07-24 21:01 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 [this message]
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
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=xmqqbjbw5cgx.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