git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/4] fast-import: add 'abort-if-invalid' mode to '--signed-commits=<mode>'

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 24, 2026, 22:22 UTC
Message-ID
<xmqqpl4syijh.fsf@gitster.g>
In-Reply-To
<20260324215513.764739-2-jltobler@gmail.com>
Justin Tobler <jltobler@gmail.com> writes:
Show 14 quoted lines
> diff --git a/builtin/fast-export.c b/builtin/fast-export.c
> index 13621b0d6a..dcbc5bc82d 100644
> --- a/builtin/fast-export.c
> +++ b/builtin/fast-export.c
> @@ -822,6 +822,9 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
>  			die(_("encountered signed commit %s; use "
>  			      "--signed-commits=<mode> to handle it"),
>  			    oid_to_hex(&commit->object.oid));
> +		case SIGN_ABORT_IF_INVALID:
> +			die(_("'abort-if-invalid' is not a valid mode for "
> +			      "git fast-export with --signed-commits=<mode>"));
>  		case SIGN_STRIP_IF_INVALID:
>  			die(_("'strip-if-invalid' is not a valid mode for "
>  			      "git fast-export with --signed-commits=<mode>"));

There are a few similar hunks in this patch to fast-export, but I am not sure what is going on here.

I may be misreading the code, but this error, and the similar one for strip-if-invalid that is already there, trigger if the command is given "--signed-commits=abort-if-invalid" on its command line, and when we see a signed commit in the range we walk to export the commits. Why shouldn't the user get the error immediately while the command is parsing the command line options? You may be sharing the underlying parse_sign_mode() with import side that may support more variants, but that is not a good excuse to make these two

    git fast-export --signed-commits=abort-if-invalid
    git fast-export --signed-commits=i-dont-know-what-i-am-doing
behave completely differently, no?

You can either move these "no, these subset of options are not available here" to fast-export.c::parse_opt_sign_mode(), or even better yet, teach parse_sign_mode() an option to say "hey, you are being called from fast-export, so pretend that you have never heard of options that are only available on fast-import" and error out right there, can't you? Or would it be too _early_ to give errors to users?

Thanks.
Previous: Justin ToblerNext: Justin Tobler
Message 3 of 7 in “fast-import: extend signed object handling modes”
  1. 0/4 fast-import: extend signed object handling modesJustin Tobler, Mar 24, 2026
  2. 1/4 fast-import: add 'abort-if-invalid' mode to '--signed-commits=<mode>'Justin Tobler, Mar 24, 2026
  3. Junio C HamanoMar 24, 2026
  4. Justin ToblerMar 25, 2026
  5. 2/4 fast-import: add 'strip-if-invalid' mode to '--signed-tags=<mode>'Justin Tobler, Mar 24, 2026
  6. 3/4 fast-import: add 'sign-if-invalid' mode to '--signed-tags=<mode>'Justin Tobler, Mar 24, 2026
  7. 4/4 fast-import: add 'abort-if-invalid' mode to '--signed-tags=<mode>'Justin Tobler, Mar 24, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.