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

Re: [PATCH 2/5] gpg-interface: support one-line summaries in print_signature_buffer()

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 6, 2020, 19:33 UTC
Message-ID
<xmqqy2uk8jmr.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20200105135616.19102-3-hji@dyntopia.com>
Hans Jerry Illikainen <hji@dyntopia.com> writes:
> Most consumers of the GPG interface use print_signature_buffer() to show
> This patch moves the one-line summary from verify_merge_signature() to
> print_signature_buffer().  It also introduces a GPG_VERIFY_SHORT flag
> that determines whether the summary should be printed.
I think the motivation makes sense.
Show 17 quoted lines
> -void print_signature_buffer(const struct signature_check *sigc, unsigned flags)
> +void print_signature_buffer(const struct object_id *oid,
> +			    const struct signature_check *sigc, int status,
> +			    unsigned flags)
>  {
>  	const char *output = flags & GPG_VERIFY_RAW ?
>  		sigc->gpg_status : sigc->gpg_output;
> +	char hex[GIT_MAX_HEXSZ + 1];
> +	char *type;
>  
>  	if (flags & GPG_VERIFY_VERBOSE && sigc->payload)
>  		fputs(sigc->payload, stdout);
>  
>  	if (flags & GPG_VERIFY_FULL && output)
>  		fputs(output, stderr);
> +
> +	if (flags & GPG_VERIFY_SHORT && oid) {

I am not sure about the wisdom of "&& oid" here. Wouldn't it be a bug for a caller who asks for _SHORT format to feed a NULL oid to us? I would understand

	if (flags & GPG_VERIFY_SHORT) {
		if (!oid)
			BUG("Caller asking for SHORT without oid???");

much better, but if there is a caller that has a legitimate need tobe able to pass NULL and still request SHORT, let's see it and discuss if it is a good idea.

For that matter, the two print routines we have immediately above share the same issue.

> +		type = xstrdup_or_null(
> +			type_name(oid_object_info(the_repository, oid, NULL)));
> +		if (!type)
> +			type = xstrdup("object");
This is minor, but I wonder if this is easier to follow.
		type = type_name(oid_object_info(the_repository, oid, NULL));
		if (!type)
			type = "object";
		type = xstrdup(type);
> +		*type = toupper(*type);
This is not helpful at all for i18n/l10n, I am afraid.
Show 8 quoted lines
> +		find_unique_abbrev_r(hex, oid, DEFAULT_ABBREV);
> +
> +		switch (sigc->result) {
> +		case 'G':
> +			if (status)
> +				error(_("%s %s has an untrusted GPG signature, "
> +					"allegedly by %s."),
> +				      type, hex, sigc->signer);
The original was of course
        die(_("Commit %s has an untrusted GPG signature, "
              "allegedly by %s."), hex, signature_check.signer);

so the message can properly localized including the typename. That is no longer true with this conversion.

You probably would need to prepare a 3-element array (one element for each of <object, commit, tag>), each element of the array being a 3-element array that holds the message for these three cases (i.e. G, N and default) instead.

Previous: Hans Jerry IllikainenNext: Hans Jerry Illikainen
Message 7 of 13 in “refactor gpg-interface and add gpg verification for clones”
  1. 0/5 refactor gpg-interface and add gpg verification for clonesHans Jerry Illikainen, Jan 5, 2020
  2. 1/5 gpg-interface: conditionally show the result in print_signature_buffer()Hans Jerry Illikainen, Jan 5, 2020
  3. Junio C HamanoJan 6, 2020
  4. 4/5 merge: verify signatures if gpg.verifySignatures is trueHans Jerry Illikainen, Jan 5, 2020
  5. Junio C HamanoJan 6, 2020
  6. 2/5 gpg-interface: support one-line summaries in print_signature_buffer()Hans Jerry Illikainen, Jan 5, 2020
  7. Junio C HamanoJan 6, 2020
  8. 3/5 commit: refactor signature verification helpersHans Jerry Illikainen, Jan 5, 2020
  9. Junio C HamanoJan 6, 2020
  10. 5/5 clone: support signature verificationHans Jerry Illikainen, Jan 5, 2020
  11. Junio C HamanoJan 5, 2020
  12. Hans Jerry IllikainenJan 7, 2020
  13. Junio C HamanoJan 7, 2020

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.