git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Elijah Newren <newren@gmail.com>
Cc: Christian Couder <christian.couder@gmail.com>,
	 git@vger.kernel.org, Patrick Steinhardt <ps@pks.im>,
	 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 v5] fast-(import|export): improve on commit signature output format
Date: Tue, 08 Jul 2025 17:03:20 -0700	[thread overview]
Message-ID: <xmqqqzyqqlh3.fsf@gitster.g> (raw)
In-Reply-To: <CABPp-BF6OvH8oh=jG_8fWoC5gW+9E+wx=uDEk1uerJTOva5isg@mail.gmail.com> (Elijah Newren's message of "Tue, 8 Jul 2025 16:08:06 -0700")

Elijah Newren <newren@gmail.com> writes:

>> +       if (!space)
>> +               die("Expected gpgsig format: 'gpgsig <hash-algo> <signature-format>', "
>> +                   "got 'gpgsig %s'", args);
>> +       *space++ = '\0';
>> +
>> +       sig->hash_algo = args;
>> +       sig->sig_format = space;
>
> Really minor nitpick, but it might be clearer to pre-increment space
> here than to increment it above.

FWIW, I find what Christian wrote easier to follow.  We find a " "
in the buffer, point it with a pointer and NUL-terminate the
substring.  We know we want to further process bytes that follow, so
the pointer is post-incremented after the NUL-termination.  The next
user of that pointer relies on the fact that the previous user
concluded its use with that post-increment.

If 'space' variable were named more genericly, like '*cp', it would
have been perfect.  Perhaps only the first half of the code was
written first, and it looked for a space, so the name was chosen,
but then later ...

>> +
>> +       /* Remove any trailing newline from format */
>> +       space = strchr(sig->sig_format, '\n');

... it is used to point at a LF X-<, at which time the author could
have renamed it to keep readers' sanity ;-)

>> +       if (space)
>> +               *space = '\0';

I also wonder what should (not "does", as I can see that the code
does not do anything) happen if we do not find the LF we were
looking for.  Is the caller of this function so loosely written that
it may or may not guarantee that the data it calls this function
with is properly terminated?

>> +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?
>
> Otherwise, I very much appreciate the work to create a testcase with
> both signature types on a single commit.

Yup, thanks, both of you.  It seems that we are getting closer to
the finish line?

Thanks.

  reply	other threads:[~2025-07-09  0:03 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-24 20:39 [PATCH] fast-(import|export): improve on the signature algorithm name Christian Couder
2025-04-24 21:19 ` Junio C Hamano
2025-04-24 21:59   ` Elijah Newren
2025-04-24 22:58     ` Junio C Hamano
2025-05-26 10:35       ` Christian Couder
2025-05-27 15:18         ` Junio C Hamano
2025-05-28 17:29           ` Junio C Hamano
2025-05-28 20:06             ` Elijah Newren
2025-05-28 21:59               ` Junio C Hamano
2025-05-28 23:15                 ` Elijah Newren
2025-05-29  3:14                   ` Junio C Hamano
2025-06-02 15:56                     ` Christian Couder
2025-06-02 15:56             ` Christian Couder
2025-06-02 16:20               ` Junio C Hamano
2025-05-26 10:34   ` Christian Couder
2025-04-24 21:41 ` Elijah Newren
2025-05-26 10:34   ` Christian Couder
2025-04-24 22:05 ` brian m. carlson
2025-05-26 10:35   ` Christian Couder
2025-04-24 23:25 ` Junio C Hamano
2025-05-26 10:33 ` [PATCH v2 0/6] extract algo information from signatures Christian Couder
2025-05-26 10:33   ` [PATCH v2 1/6] gpg-interface: simplify ssh fingerprint parsing Christian Couder
2025-05-26 10:33   ` [PATCH v2 2/6] gpg-interface: use left shift to define GPG_VERIFY_* Christian Couder
2025-05-26 10:33   ` [PATCH v2 3/6] doc/verify-commit: update and improve the whole doc Christian Couder
2025-05-26 10:33   ` [PATCH v2 4/6] gpg-interface: extract hash algorithm from signature status output Christian Couder
2025-05-26 10:33   ` [PATCH v2 5/6] gpg-interface: extract SSH key type " Christian Couder
2025-05-26 10:33   ` [PATCH v2 6/6] verify-commit: add a --summary flag Christian Couder
2025-05-26 16:03   ` [PATCH v2 0/6] extract algo information from signatures Elijah Newren
2025-06-19 13:38     ` Christian Couder
2025-06-02 22:17   ` brian m. carlson
2025-06-19 13:37     ` Christian Couder
2025-06-18 15:18   ` [PATCH v3] fast-(import|export): improve on commit signature output format Christian Couder
2025-06-19 13:36     ` [PATCH v4] " Christian Couder
2025-06-19 14:55       ` Junio C Hamano
2025-07-08  9:16         ` Christian Couder
2025-06-19 21:44       ` Elijah Newren
2025-06-20 16:12         ` Christian Couder
2025-06-20 19:20           ` Junio C Hamano
2025-07-08  9:16             ` Christian Couder
2025-06-26 19:11           ` Elijah Newren
2025-07-08  9:16             ` Christian Couder
2025-07-07 22:58       ` Junio C Hamano
2025-07-08  3:35         ` Christian Couder
2025-07-08  5:03           ` Junio C Hamano
2025-07-08  6:38             ` Patrick Steinhardt
2025-07-08 11:08               ` Christian Couder
2025-07-08 16:38                 ` Junio C Hamano
2025-07-09  0:19                   ` Christian Couder
2025-07-09 15:35                     ` Junio C Hamano
2025-07-10  8:25                     ` Patrick Steinhardt
2025-07-10 15:29                       ` Christian Couder
2025-07-10 15:33                       ` Junio C Hamano
2025-07-08 10:17             ` Christian Couder
2025-07-08  9:17       ` [PATCH v5] " Christian Couder
2025-07-08 21:58         ` Junio C Hamano
2025-07-08 23:08         ` Elijah Newren
2025-07-09  0:03           ` Junio C Hamano [this message]
2025-07-09  0:10             ` Elijah Newren
2025-07-09 10:18             ` Christian Couder
2025-07-09 10:15           ` Christian Couder
2025-07-09 14:12         ` [PATCH v6] " Christian Couder
2025-07-09 23:14           ` Junio C Hamano
2025-07-14 21:07           ` Elijah Newren
2025-07-14 21:23             ` Junio C Hamano
2025-07-25 16:11               ` 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=xmqqqzyqqlh3.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=chriscool@tuxfamily.org \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=newren@gmail.com \
    --cc=peff@peff.net \
    --cc=ps@pks.im \
    --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).