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

Re: [PATCH 4/5] merge: verify signatures if gpg.verifySignatures is true

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 6, 2020, 21:01 UTC
Message-ID
<xmqqa7708flc.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20200105135616.19102-5-hji@dyntopia.com>
Hans Jerry Illikainen <hji@dyntopia.com> writes:
Show 6 quoted lines
> @@ -610,6 +610,8 @@ static int git_merge_config(const char *k, const char *v, void *cb)
>  		show_diffstat = git_config_bool(k, v);
>  	else if (!strcmp(k, "merge.verifysignatures"))
>  		verify_signatures = git_config_bool(k, v);
> +	else if (!strcmp(k, "gpg.verifysignatures") && verify_signatures < 0)
> +		verify_signatures = git_config_bool(k, v);

Hmm, the next person who attempts to generalize the mechanism further would have a hard time introducing a fallback configuration that is even common than "gpg" when s/he has to start with this code, no? That is, this patch introduced "gpg.verifysignatures is used when merge.verifysignatures is not defined" and with the two level override the code works OK, but to implement "if neither gpg.* or merge.* is defined, common.verifysignatures is used instead", the above part needs to be dismantled and redone.

Keeping the "initialize verify_signatures to -1 (unspecified)" from this patch, setting a separate gpg_verify_signatures variable upon seeing gpg.verifysignatures, and consolidating the final finding after git_config(git_merge_config, NULL) returns into verify_signatures like so:

	init_diff_ui_defaults();
	git_config(git_merge_config, NULL);

+ if (verify_signatures < 0) + verify_signatures = (0 <= gpg_verify_signatures) + ? gpg_verify_signatures + : 0;

would be more in line with the way we arrange multiple configuration variables to serve as fallback defaults. And that is more easily extensible.

Also with such an arrangement, "if (verify_signatures == 1)" we see below will become unnecessary, which is another plus.

Thanks.
Show 21 quoted lines
>  	else if (!strcmp(k, "pull.twohead"))
>  		return git_config_string(&pull_twohead, k, v);
>  	else if (!strcmp(k, "pull.octopus"))
> @@ -1399,7 +1401,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
>  		if (remoteheads->next)
>  			die(_("Can merge only exactly one commit into empty head"));
>  
> -		if (verify_signatures &&
> +		if (verify_signatures == 1 &&
>  		    gpg_verify_commit(&remoteheads->item->object.oid, NULL,
>  				      NULL, gpg_flags))
>  			die(_("Signature verification failed"));
> @@ -1423,7 +1425,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
>  		usage_with_options(builtin_merge_usage,
>  			builtin_merge_options);
>  
> -	if (verify_signatures) {
> +	if (verify_signatures == 1) {
>  		for (p = remoteheads; p; p = p->next) {
>  			if (gpg_verify_commit(&p->item->object.oid, NULL, NULL,
>  					      gpg_flags))
Previous: Hans Jerry IllikainenNext: Hans Jerry Illikainen
Message 5 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.