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

Re: [PATCH v5] fast-(import|export): improve on commit signature output format

From
Christian Couder <christian.couder@gmail.com>
Date
Jul 9, 2025, 10:15 UTC
Message-ID
<CAP8UFD2qpFTy0jtrKk4iQ1C+7dZDV7Abqrqz3J6qx2T4Jy0ESA@mail.gmail.com>
In-Reply-To
<CABPp-BF6OvH8oh=jG_8fWoC5gW+9E+wx=uDEk1uerJTOva5isg@mail.gmail.com>
On Wed, Jul 9, 2025 at 1:08 AM Elijah Newren <newren@gmail.com> wrote:
>
> On Tue, Jul 8, 2025 at 2:18 AM Christian Couder
> <christian.couder@gmail.com> wrote:
Show 29 quoted lines
> > diff --git a/Documentation/git-fast-import.adoc b/Documentation/git-fast-import.adoc
> > index 250d866652..89dec1108f 100644
> > --- a/Documentation/git-fast-import.adoc
> > +++ b/Documentation/git-fast-import.adoc
> > @@ -445,7 +445,7 @@ one).
> >         original-oid?
> >         ('author' (SP <name>)? SP LT <email> GT SP <when> LF)?
> >         'committer' (SP <name>)? SP LT <email> GT SP <when> LF
> > -       ('gpgsig' SP <alg> LF data)?
> > +       ('gpgsig' SP <algo> SP <format> LF data)?
> >         ('encoding' SP <encoding> LF)?
> >         data
> >         ('from' SP <commit-ish> LF)?
> > @@ -518,13 +518,37 @@ their syntax.
> >  ^^^^^^^^
> >
> >  The optional `gpgsig` command is used to include a PGP/GPG signature
> > -that signs the commit data.
> > +or other cryptographic signature that signs the commit data.
> >
> > -Here <alg> specifies which hashing algorithm is used for this
> > -signature, either `sha1` or `sha256`.
> > +....
> > +       'gpgsig' SP <git-hash-algo> SP <signature-format> LF
> > +       data
>
> Should the `data` be moved to the line above, just to make it clear
> it's associated with it?  (Similar to the first line you changed in
> git-fast-import.adoc?)
Yeah, I have changed it in my current version.
Show 12 quoted lines
> > +....
> > +
> > +The `gpgsig` command takes two arguments:
> > +
> > +* `<git-hash-algo>` specifies which Git object format this signature
> > +  applies to, either `sha1` or `sha256`. This allows to know which
> > +  representation of the commit was signed (the SHA-1 or the SHA-256
> > +  version) which helps with both signature verification and
> > +  interoperability between repos with different hash functions.
>
> Should there also be a note added that fast-import is limited on what
> signatures it can verify if extensions.compatObjectFormat is not set?

It cannot yet verify signatures, but yeah it's probably a good idea to say that setting this config option might help with verifying signatures when it will be able to do it. See below.

Show 16 quoted lines
> > +* `<signature-format>` specifies the type of signature, such as
> > +  `openpgp`, `x509`, `ssh`, or `unknown`. This is a convenience for
> > +  tools that process the stream, so they don't have to parse the ASCII
> > +  armor to identify the signature type.
> > +
> > +A commit may have at most one signature for the SHA-1 object format
> > +(stored in the "gpgsig" header) and one for the SHA-256 object format
> > +(stored in the "gpgsig-sha256" header).
> > +
> > +See below for a detailed description of the `data` command which
> > +contains the raw signature data.
> > +
> > +Signatures are not yet checked in the current implementation though.
>
> ...or maybe that extra note could be added as a parenthetical comment
> here for now?
Yeah, in my current version, there is:

"Signatures are not yet checked in the current implementation though. (Already setting the `extensions.compatObjectFormat` configuration option might help with verifying both SHA-1 and SHA-256 object format signatures when it will be implemented.)"

[...]
Show 23 quoted lines
> > +test_expect_success GPG 'export and import of doubly signed commit' '
> > +       git -C explicit-sha256 fast-export --signed-commits=verbatim dual-signed >output &&
> > +       test_grep -E "^gpgsig sha1 openpgp" output &&
> > +       test_grep -E "^gpgsig sha256 openpgp" output &&
> > +
> > +       (
> > +               cd new &&
> > +               git fast-import &&
> > +               git cat-file commit refs/heads/dual-signed >actual &&
> > +               test_grep -E "^gpgsig " actual &&
> > +               test_grep -E "^gpgsig-sha256 " actual &&
> > +               IMPORTED=$(git rev-parse refs/heads/dual-signed) &&
> > +               if test "$GIT_DEFAULT_HASH" = "sha1"
> > +               then
> > +                       test $SHA1_B = $IMPORTED
> > +               else
> > +                       test $SHA256_B = $IMPORTED
> > +               fi
> > +       ) <output
>
> This last bit seems a bit fragile; could the redirection of output to
> the stdin of `git fast-import` be made specific to that one line
> instead of to the whole range of commands?

I used the same style as many other tests in this file. For example there are already:

test_expect_success GPG 'signed-commits=verbatim' '
    git fast-export --signed-commits=verbatim --reencode=no
commit-signing >output &&
    grep "^gpgsig sha" output &&
    grep "encoding ISO-8859-1" output &&
    (
        cd new &&
        git fast-import &&
        STRIPPED=$(git rev-parse --verify refs/heads/commit-signing) &&
        test $COMMIT_SIGNING = $STRIPPED
    ) <output
'
test_expect_success GPG 'signed-commits=warn-verbatim' '
    git fast-export --signed-commits=warn-verbatim --reencode=no
commit-signing >output 2>err &&
    grep "^gpgsig sha" output &&
    grep "encoding ISO-8859-1" output &&
    test -s err &&
    (
        cd new &&
        git fast-import &&
        STRIPPED=$(git rev-parse --verify refs/heads/commit-signing) &&
        test $COMMIT_SIGNING = $STRIPPED
    ) <output
'
etc.

So to keep a consistent style in the tests, I would likely have to add a preparatory commit that changes the style of all these existing tests. Not sure it's worth it at this point.

> Otherwise, I very much appreciate the work to create a testcase with
> both signature types on a single commit.
Thanks for the kind words and for your reviews!
Previous: Christian CouderNext: Christian Couder
Message 60 of 65 in “fast-(import|export): improve on the signature algorithm name”
  1. fast-(import|export): improve on the signature algorithm nameChristian Couder, Apr 24, 2025
  2. Junio C HamanoApr 24, 2025
  3. Elijah NewrenApr 24, 2025
  4. Junio C HamanoApr 24, 2025
  5. Christian CouderMay 26, 2025
  6. Junio C HamanoMay 27, 2025
  7. Junio C HamanoMay 28, 2025
  8. Elijah NewrenMay 28, 2025
  9. Junio C HamanoMay 28, 2025
  10. Elijah NewrenMay 28, 2025
  11. Junio C HamanoMay 29, 2025
  12. Christian CouderJun 2, 2025
  13. Christian CouderJun 2, 2025
  14. Junio C HamanoJun 2, 2025
  15. Christian CouderMay 26, 2025
  16. Elijah NewrenApr 24, 2025
  17. Christian CouderMay 26, 2025
  18. brian m. carlsonApr 24, 2025
  19. Christian CouderMay 26, 2025
  20. Junio C HamanoApr 24, 2025
  21. 0/6 extract algo information from signaturesChristian Couder, May 26, 2025
  22. 1/6 gpg-interface: simplify ssh fingerprint parsingChristian Couder, May 26, 2025
  23. 2/6 gpg-interface: use left shift to define GPG_VERIFY_*Christian Couder, May 26, 2025
  24. 3/6 doc/verify-commit: update and improve the whole docChristian Couder, May 26, 2025
  25. 4/6 gpg-interface: extract hash algorithm from signature status outputChristian Couder, May 26, 2025
  26. 5/6 gpg-interface: extract SSH key type from signature status outputChristian Couder, May 26, 2025
  27. 6/6 verify-commit: add a --summary flagChristian Couder, May 26, 2025
  28. Elijah NewrenMay 26, 2025
  29. Christian CouderJun 19, 2025
  30. brian m. carlsonJun 2, 2025
  31. Christian CouderJun 19, 2025
  32. fast-(import|export): improve on commit signature output formatChristian Couder, Jun 18, 2025
  33. fast-(import|export): improve on commit signature output formatChristian Couder, Jun 19, 2025
  34. Junio C HamanoJun 19, 2025
  35. Christian CouderJul 8, 2025
  36. Elijah NewrenJun 19, 2025
  37. Christian CouderJun 20, 2025
  38. Junio C HamanoJun 20, 2025
  39. Christian CouderJul 8, 2025
  40. Elijah NewrenJun 26, 2025
  41. Christian CouderJul 8, 2025
  42. Junio C HamanoJul 7, 2025
  43. Christian CouderJul 8, 2025
  44. Junio C HamanoJul 8, 2025
  45. Patrick SteinhardtJul 8, 2025
  46. Christian CouderJul 8, 2025
  47. Junio C HamanoJul 8, 2025
  48. Christian CouderJul 9, 2025
  49. Junio C HamanoJul 9, 2025
  50. Patrick SteinhardtJul 10, 2025
  51. Christian CouderJul 10, 2025
  52. Junio C HamanoJul 10, 2025
  53. Christian CouderJul 8, 2025
  54. fast-(import|export): improve on commit signature output formatChristian Couder, Jul 8, 2025
  55. Junio C HamanoJul 8, 2025
  56. Elijah NewrenJul 8, 2025
  57. Junio C HamanoJul 9, 2025
  58. Elijah NewrenJul 9, 2025
  59. Christian CouderJul 9, 2025
  60. Christian CouderJul 9, 2025
  61. fast-(import|export): improve on commit signature output formatChristian Couder, Jul 9, 2025
  62. Junio C HamanoJul 9, 2025
  63. Elijah NewrenJul 14, 2025
  64. Junio C HamanoJul 14, 2025
  65. Christian CouderJul 25, 2025

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.