From: Patrick Steinhardt <ps@pks.im>
To: Justin Tobler <jltobler@gmail.com>
Cc: git@vger.kernel.org, sandals@crustytoothpaste.net,
christian.couder@gmail.com
Subject: Re: [PATCH 2/2] fast-import: add mode to re-sign invalid commit signatures
Date: Tue, 24 Feb 2026 10:33:34 +0100 [thread overview]
Message-ID: <aZ1wblYGQssyNYsk@pks.im> (raw)
In-Reply-To: <20260223194146.3476768-3-jltobler@gmail.com>
On Mon, Feb 23, 2026 at 01:41:46PM -0600, Justin Tobler wrote:
> With git-fast-import(1), handling of signed commits is controlled via
> the `--signed-commits=<mode>` option. When an invalid signature is
> encountered, a user may want the option to re-sign the commit as opposed
> to just stripping the signature. To faciliate this, introduce a
> "re-sign-if-invalid" mode for the `--signed-commits` option.
>
> Note that commits are re-signed using only the repository object format
> hash algorithm. If a commit has an additional signature due to the
> `compatObjectFormat` repository extension being set, the other signature
> is stripped.
This part here might use some explanation why this part is not done so
that a future reader that ends up here doesn't have to wonder whether
this is done with intent, or whether this was done because it was hard
to do.
> diff --git a/Documentation/git-fast-import.adoc b/Documentation/git-fast-import.adoc
> index 479c4081da..b902a6e2b0 100644
> --- a/Documentation/git-fast-import.adoc
> +++ b/Documentation/git-fast-import.adoc
> @@ -86,6 +86,9 @@ already trusted to run their own code.
> * `strip-if-invalid` will check signatures and, if they are invalid,
> will strip them and display a warning. The validation is performed
> in the same way as linkgit:git-verify-commit[1] does it.
> +* `re-sign-if-invalid` is the same as `strip-if-invalid`, but additionally the
> + commits with invalid signatures are signed again, so that old invalid
> + signatures are replaced with new valid ones.
Okay. It's a bit curious to say it's the "same as `strip-if-invalid`",
but I get what you mean by this, and I think a user would, too.
> diff --git a/builtin/fast-import.c b/builtin/fast-import.c
> index b8a7757cfd..e34a373d2f 100644
> --- a/builtin/fast-import.c
> +++ b/builtin/fast-import.c
> @@ -2836,10 +2836,11 @@ static void finalize_commit_buffer(struct strbuf *new_data,
> strbuf_addbuf(new_data, msg);
> }
>
> -static void handle_strip_if_invalid(struct strbuf *new_data,
> - struct signature_data *sig_sha1,
> - struct signature_data *sig_sha256,
> - struct strbuf *msg)
> +static void handle_invalid_signature(struct strbuf *new_data,
> + struct signature_data *sig_sha1,
> + struct signature_data *sig_sha256,
> + struct strbuf *msg,
> + enum sign_mode mode)
> {
> struct strbuf tmp_buf = STRBUF_INIT;
> struct signature_check signature_check = { 0 };
Should we maybe call this `handle_signature_if_invalid()`? Otherwise it
sounds as if we already know the signature was invalid.
> @@ -2866,6 +2867,30 @@ static void handle_strip_if_invalid(struct strbuf *new_data,
> warning(_("stripping invalid signature for commit\n"
> " allegedly by %s"), signer);
I wonder: does it still make sense to warn about those stripped
signatures in case we re-sign anyway?
> + if (mode == SIGN_RESIGN_IF_INVALID) {
> + struct strbuf signature = STRBUF_INIT;
> + struct strbuf payload = STRBUF_INIT;
> + char *key = get_signing_key();
> +
> + /*
> + * Commits are resigned using the repository object
Poor commits. Maybe s/resigned/re-signed/?
> + * format hash algorithm only. Consequently if
> + * extensions.compatObjectFormat is set, the
> + * compatability hash is not currently used to
> + * additionally sign the commit. If the commit payload
> + * were reconstructed in the compatability format, it
> + * would be possible to generate the other signature
> + * accordingly though.
> + */
Same as in the commit message, we should document whether this is done
intentionally, or whether it may require more work going forward. If the
latter, it might make sense to add a NEEDSWORK comment.
I think meanwhile though it's okay that we don't handle compatibility
hashes yet.
> diff --git a/gpg-interface.c b/gpg-interface.c
> index 87fb6605fb..e7eb42d9d6 100644
> --- a/gpg-interface.c
> +++ b/gpg-interface.c
> @@ -1156,6 +1156,8 @@ int parse_sign_mode(const char *arg, enum sign_mode *mode)
> *mode = SIGN_STRIP;
> else if (!strcmp(arg, "strip-if-invalid"))
> *mode = SIGN_STRIP_IF_INVALID;
> + else if (!strcmp(arg, "re-sign-if-invalid"))
> + *mode = SIGN_RESIGN_IF_INVALID;
> else
> return -1;
> return 0;
One thing I wonder here is which signing key is actually in use, and how
the user would specify it. In git-commit(1) you can for example pass
"--gpg-sign=<key-id>" to specify the key. Do we want to allow the same
here, where you can pass "--signed-commits=re-sign-if-invalid[=<gpg-key>]"?
Thanks!
Patrick
next prev parent reply other threads:[~2026-02-24 9:33 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-23 19:41 [PATCH 0/2] fast-import: add mode to re-sign invalid commit signatures Justin Tobler
2026-02-23 19:41 ` [PATCH 1/2] commit: remove unused forward declaration Justin Tobler
2026-02-24 9:35 ` Patrick Steinhardt
2026-02-23 19:41 ` [PATCH 2/2] fast-import: add mode to re-sign invalid commit signatures Justin Tobler
2026-02-24 9:33 ` Patrick Steinhardt [this message]
2026-02-24 18:33 ` Justin Tobler
2026-02-24 13:40 ` [PATCH 0/2] " Christian Couder
2026-02-24 22:41 ` brian m. carlson
2026-02-24 22:45 ` Junio C Hamano
2026-03-02 22:49 ` Justin Tobler
2026-03-06 20:53 ` [PATCH v2 0/3] " Justin Tobler
2026-03-06 20:53 ` [PATCH v2 1/3] commit: remove unused forward declaration Justin Tobler
2026-03-06 20:53 ` [PATCH v2 2/3] gpg-interface: introduce sign_buffer_with_key() Justin Tobler
2026-03-10 9:01 ` Christian Couder
2026-03-10 18:04 ` Justin Tobler
2026-03-06 20:53 ` [PATCH v2 3/3] fast-import: add mode to re-sign invalid commit signatures Justin Tobler
2026-03-10 9:27 ` Christian Couder
2026-03-10 18:09 ` Justin Tobler
2026-03-10 20:11 ` [PATCH v3 0/3] " Justin Tobler
2026-03-10 20:11 ` [PATCH v3 1/3] commit: remove unused forward declaration Justin Tobler
2026-03-10 22:29 ` Junio C Hamano
2026-03-10 20:11 ` [PATCH v3 2/3] gpg-interface: introduce sign_buffer_with_key() Justin Tobler
2026-03-10 22:33 ` Junio C Hamano
2026-03-10 20:11 ` [PATCH v3 3/3] fast-import: add mode to re-sign invalid commit signatures Justin Tobler
2026-03-10 20:49 ` [PATCH v3 0/3] " Junio C Hamano
2026-03-10 21:06 ` Justin Tobler
2026-03-10 21:20 ` Junio C Hamano
2026-03-10 22:13 ` Justin Tobler
2026-03-10 22:39 ` Junio C Hamano
2026-03-10 23:03 ` Justin Tobler
2026-03-11 17:31 ` [PATCH v4 " Justin Tobler
2026-03-11 17:31 ` [PATCH v4 1/3] commit: remove unused forward declaration Justin Tobler
2026-03-11 17:31 ` [PATCH v4 2/3] gpg-interface: introduce sign_buffer_with_key() Justin Tobler
2026-03-12 10:22 ` Patrick Steinhardt
2026-03-12 13:58 ` Justin Tobler
2026-03-11 17:31 ` [PATCH v4 3/3] fast-import: add mode to sign commits with invalid signatures Justin Tobler
2026-03-12 10:23 ` Patrick Steinhardt
2026-03-12 14:08 ` Justin Tobler
2026-03-12 14:22 ` Patrick Steinhardt
2026-03-12 17:21 ` Justin Tobler
2026-03-12 19:22 ` [PATCH v5 0/3] fast-import: add mode to re-sign invalid commit signatures Justin Tobler
2026-03-12 19:22 ` [PATCH v5 1/3] commit: remove unused forward declaration Justin Tobler
2026-03-12 19:22 ` [PATCH v5 2/3] gpg-interface: allow sign_buffer() to use default signing key Justin Tobler
2026-03-12 20:20 ` Junio C Hamano
2026-03-12 20:24 ` Justin Tobler
2026-03-12 19:22 ` [PATCH v5 3/3] fast-import: add mode to sign commits with invalid signatures Justin Tobler
2026-03-12 20:20 ` Junio C Hamano
2026-03-12 20:29 ` Justin Tobler
2026-03-12 23:58 ` Jeff King
2026-03-13 0:17 ` Justin Tobler
2026-03-12 20:20 ` [PATCH v5 0/3] fast-import: add mode to re-sign invalid commit signatures Junio C Hamano
2026-03-12 20:30 ` Justin Tobler
2026-03-13 1:39 ` [PATCH v6 " Justin Tobler
2026-03-13 1:39 ` [PATCH v6 1/3] commit: remove unused forward declaration Justin Tobler
2026-03-13 1:39 ` [PATCH v6 2/3] gpg-interface: allow sign_buffer() to use default signing key Justin Tobler
2026-03-13 6:31 ` Patrick Steinhardt
2026-03-13 1:39 ` [PATCH v6 3/3] fast-import: add mode to sign commits with invalid signatures Justin Tobler
2026-03-13 6:31 ` Patrick Steinhardt
2026-03-13 4:29 ` [PATCH v6 0/3] fast-import: add mode to re-sign invalid commit signatures Junio C Hamano
2026-03-13 6:31 ` Patrick Steinhardt
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=aZ1wblYGQssyNYsk@pks.im \
--to=ps@pks.im \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=jltobler@gmail.com \
--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