From: Junio C Hamano <gitster@pobox.com>
To: Erik Cervin-Edin <erik@cervined.in>
Cc: git@vger.kernel.org, phillip.wood123@gmail.com
Subject: Re: [PATCH v5 2/3] commit: allow -m/-F for all --fixup variants
Date: Sat, 28 Nov 2026 17:51:01 -0800 [thread overview]
Message-ID: <xmqqik1gs8vu.fsf@gitster.g> (raw)
In-Reply-To: <051b659965fb31ee7c074d0cd31719fdf2027701.1795867565.git.erik@cervined.in> (Erik Cervin-Edin's message of "Sat, 28 Nov 2026 13:14:00 +0100")
Erik Cervin-Edin <erik@cervined.in> writes:
> Allow -m and -F to supply the message body for all --fixup variants,
> mirroring the flow of a regular commit. With --fixup=amend/reword the
> given message replaces the one that would otherwise be copied from the
> target commit. Options -c and -C are handled in the next commit.
The preliminary move in [1/3] made this step a quite plesant read.
> diff --git a/builtin/commit.c b/builtin/commit.c
> index 698823d4fa..e0fac284bc 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -793,8 +793,6 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
> repo_format_commit_message(the_repository, c, fmt, &sb,
> &ctx);
> free(fmt);
> - if (have_option_m && !strcmp(fixup_prefix, "amend"))
> - die(_("options '%s' and '%s:%s' cannot be used together"), "-m", "--fixup", fixup_message);
> } else if (squash_message) {
> /*
> * Insert the proper subject line before other commit
> @@ -1331,9 +1329,8 @@ static int parse_and_validate_options(int argc, const char *argv[],
> }
> if (fixup_message && squash_message)
> die(_("options '%s' and '%s' cannot be used together"), "--squash", "--fixup");
> - die_for_incompatible_opt4(!!use_message, "-C",
> + die_for_incompatible_opt3(!!use_message, "-C",
> !!edit_message, "-c",
> - !!logfile, "-F",
> !!fixup_message, "--fixup");
> die_for_incompatible_opt4(have_option_m, "-m",
> !!edit_message, "-c",
Covering all the possible interactions that can conflict and validating
that coverage is tricky. I tried to walk through the code flow but I am
not convinced myself, so let me think aloud.
Because logfile and have_option_m still clear use_editor early in
parse_and_validate_options() and free template_file, neither
commit.template nor an unintended editor session can interfere, while an
explicit -e/--edit still overrides use_editor via edit_flag as it does
for regular commits. For --fixup=amend: and --fixup=reword:,
cmd_commit() checks message_is_empty() past commit_subject_length()
whenever the message starts with "amend! ", so an empty -m or -F body
still aborts unless --allow-empty-message is passed.
> @@ -526,8 +555,7 @@ test_expect_success 'invalid message options when using --fixup' '
> git add foo &&
> test_must_fail git commit --fixup HEAD~1 --squash HEAD~2 &&
> test_must_fail git commit --fixup HEAD~1 -C HEAD~2 &&
> - test_must_fail git commit --fixup HEAD~1 -c HEAD~2 &&
> - test_must_fail git commit --fixup HEAD~1 -F log
> + test_must_fail git commit --fixup HEAD~1 -c HEAD~2
> '
We lost "-F log" check, so the 'echo' before the precontext of this hunk
that sets up the contents of the log file can and should be removed,
too.
next prev parent reply other threads:[~2026-11-29 1:51 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-18 11:22 [PATCH 0/1] commit: allow -m/-F with --fixup=amend: or reword: erik
2026-05-18 11:22 ` [PATCH 1/1] " erik
2026-05-18 12:39 ` Junio C Hamano
2026-05-18 15:27 ` Phillip Wood
2026-05-24 15:00 ` Erik Cervin Edin
2026-05-26 10:47 ` [PATCH v2 0/2] commit: allow -m/-F/-c/-C for all --fixup variations erik
2026-05-26 10:47 ` [PATCH v2 1/2] commit: allow -m/-F for all kinds of --fixup erik
2026-05-26 10:47 ` [PATCH v2 2/2] commit: allow -c/-C " erik
2026-08-26 21:31 ` Junio C Hamano
2026-09-04 18:47 ` Erik Cervin Edin
2026-09-22 13:04 ` [PATCH v3 0/2] commit: allow -m/-F/-c/-C for all --fixup variations erik
2026-09-22 13:04 ` [PATCH v3 1/2] commit: allow -m/-F for all kinds of --fixup erik
2026-10-21 15:11 ` Phillip Wood
2026-09-22 13:04 ` [PATCH v3 2/2] commit: allow -c/-C " erik
2026-10-21 15:10 ` Phillip Wood
2026-10-21 15:13 ` [PATCH v3 0/2] commit: allow -m/-F/-c/-C for all --fixup variations Phillip Wood
2026-11-05 14:51 ` Erik Cervin-Edin
2026-11-09 10:54 ` Phillip Wood
2026-11-24 23:32 ` [PATCH v4 0/3] commit: allow -m/-F/-c/-C for all --fixup variants Erik Cervin-Edin
2026-11-24 23:32 ` [PATCH v4 1/3] commit: write the --fixup subject the way --squash does Erik Cervin-Edin
2026-11-24 23:32 ` [PATCH v4 2/3] commit: allow -m/-F for all --fixup variants Erik Cervin-Edin
2026-11-24 23:32 ` [PATCH v4 3/3] commit: allow -c/-C " Erik Cervin-Edin
2026-11-25 14:37 ` [PATCH v4 0/3] commit: allow -m/-F/-c/-C " Phillip Wood
2026-11-26 9:17 ` erik88
2026-11-26 15:07 ` Phillip Wood
2026-11-28 12:13 ` [PATCH v5 " Erik Cervin-Edin
2026-11-28 12:13 ` [PATCH v5 1/3] commit: write the --fixup subject the way --squash does Erik Cervin-Edin
2026-11-29 1:31 ` Junio C Hamano
2026-11-28 12:14 ` [PATCH v5 2/3] commit: allow -m/-F for all --fixup variants Erik Cervin-Edin
2026-11-29 1:51 ` Junio C Hamano [this message]
2026-11-28 12:14 ` [PATCH v5 3/3] commit: allow -c/-C " Erik Cervin-Edin
2026-11-29 18:34 ` Junio C Hamano
2026-11-30 14:28 ` Phillip Wood
2026-11-30 14:29 ` [PATCH v5 0/3] commit: allow -m/-F/-c/-C " 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=xmqqik1gs8vu.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=erik@cervined.in \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.