From: Patrick Steinhardt <ps@pks.im>
To: Christian Couder <christian.couder@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
Elijah Newren <newren@gmail.com>, Jeff King <peff@peff.net>,
"brian m . carlson" <sandals@crustytoothpaste.net>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Christian Couder <chriscool@tuxfamily.org>
Subject: Re: [PATCH v2 2/2] fast-import: add '--signed-commits=<mode>' option
Date: Mon, 15 Sep 2025 08:27:31 +0200 [thread overview]
Message-ID: <aMex06JNPVeHaw_d@pks.im> (raw)
In-Reply-To: <20250912124042.2523683-3-christian.couder@gmail.com>
On Fri, Sep 12, 2025 at 02:40:42PM +0200, Christian Couder wrote:
> diff --git a/Documentation/git-fast-import.adoc b/Documentation/git-fast-import.adoc
> index 3144ffcdb6..90f242d058 100644
> --- a/Documentation/git-fast-import.adoc
> +++ b/Documentation/git-fast-import.adoc
> diff --git a/builtin/fast-import.c b/builtin/fast-import.c
> index 2c35f9345d..890f05de4d 100644
> --- a/builtin/fast-import.c
> +++ b/builtin/fast-import.c
> @@ -2817,19 +2819,39 @@ static void parse_new_commit(const char *arg)
> if (!committer)
> die("Expected committer but didn't get one");
>
> - /* Process signatures (up to 2: one "sha1" and one "sha256") */
> while (skip_prefix(command_buf.buf, "gpgsig ", &v)) {
> struct signature_data sig = { NULL, NULL, STRBUF_INIT };
>
> - parse_one_signature(&sig, v);
> + if (signed_commit_mode == SIGN_ABORT)
> + die(_("encountered signed commit; use "
> + "--signed-commits=<mode> to handle it"));
>
> - if (!strcmp(sig.hash_algo, "sha1"))
> - store_signature(&sig_sha1, &sig, "SHA-1");
> - else if (!strcmp(sig.hash_algo, "sha256"))
> - store_signature(&sig_sha256, &sig, "SHA-256");
> - else
> - BUG("parse_one_signature() returned unknown hash algo");
> + parse_one_signature(&sig, v);
>
> + switch (signed_commit_mode) {
> + case SIGN_ABORT:
> + BUG("SIGN_ABORT should be handled before calling parse_one_signature()");
> + break;
Let's be defensive and convert this into a `default:` case so that any
unhandled value will cause a BUG.
> + case SIGN_WARN_VERBATIM:
> + warning(_("importing a commit signature verbatim"));
> + /* fallthru */
> + case SIGN_VERBATIM:
> + if (!strcmp(sig.hash_algo, "sha1"))
> + store_signature(&sig_sha1, &sig, "SHA-1");
> + else if (!strcmp(sig.hash_algo, "sha256"))
> + store_signature(&sig_sha256, &sig, "SHA-256");
> + else
> + die(_("parse_one_signature() returned unknown hash algo"));
> + break;
> + case SIGN_WARN_STRIP:
> + warning(_("stripping a commit signature"));
> + /* fallthru */
> + case SIGN_STRIP:
> + /* Just discard signature data */
> + strbuf_release(&sig.data);
> + free(sig.hash_algo);
> + break;
> + }
> read_next_command();
> }
>
Other than that the patch looks good to me, thanks!
Patrick
next prev parent reply other threads:[~2025-09-15 6:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-12 12:40 [PATCH v2 0/2] fast-import: start controlling how commit signatures are handled Christian Couder
2025-09-12 12:40 ` [PATCH v2 1/2] gpg-interface: refactor 'enum sign_mode' parsing Christian Couder
2025-09-12 12:40 ` [PATCH v2 2/2] fast-import: add '--signed-commits=<mode>' option Christian Couder
2025-09-12 12:45 ` Christian Couder
2025-09-15 6:27 ` Patrick Steinhardt [this message]
2025-09-15 10:17 ` Christian Couder
2025-09-15 10:56 ` Patrick Steinhardt
2025-09-17 18:23 ` Christian Couder
2025-09-17 18:14 ` [PATCH v3 0/2] fast-import: start controlling how commit signatures are handled Christian Couder
2025-09-17 18:14 ` [PATCH v3 1/2] gpg-interface: refactor 'enum sign_mode' parsing Christian Couder
2025-09-17 18:14 ` [PATCH v3 2/2] fast-import: add '--signed-commits=<mode>' option Christian Couder
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=aMex06JNPVeHaw_d@pks.im \
--to=ps@pks.im \
--cc=Johannes.Schindelin@gmx.de \
--cc=chriscool@tuxfamily.org \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=newren@gmail.com \
--cc=peff@peff.net \
--cc=sandals@crustytoothpaste.net \
/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).