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

Re: [PATCH 3/4] push: accept push options

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 7, 2016, 20:52 UTC
Message-ID
<xmqq60shp3w9.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20160707011218.3690-4-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
Show 5 quoted lines
> +-L::
> +--push-option::
> +	Transmit the given string to the server, which passes them to
> +	the pre-receive as well as the post-receive hook. Only C strings
> +	containing no new lines are allowed.

This is to affect what happens at the remote end, so I would have understood "-R". I also would have understood "-P" as a short-hand for "--push-option". What is the justification of "-L"?

What does "C strings" mean? Did you mean to say "A sequence of bytes excluding NUL is passed verbatim"?

I do not think I saw anything in the code I reviewed so far that requires "no LF" limitation.

... Ahh, OK, you want to make sure that push-options are one-per-line in the push certificate. While I do not think it is absolutely necessary, starting with a possibly tighter than necessary limitation is much better than starting loose and having to tighten it later.

Show 6 quoted lines
>  	} else {
>  		struct transport *transport =
>  			transport_get(remote, NULL);
> -
> +		if (flags & TRANSPORT_PUSH_OPTIONS)
> +			transport->push_options = push_options;

The result would be easier to read without the removal of a blank that separates decl/defn and stmt here.

Show 5 quoted lines
> @@ -533,6 +542,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
>  		  0, "signed", &push_cert, "yes|no|if-asked", N_("GPG sign the push"),
>  		  PARSE_OPT_OPTARG, option_parse_push_signed },
>  		OPT_BIT(0, "atomic", &flags, N_("request atomic transaction on remote side"), TRANSPORT_PUSH_ATOMIC),
> +		OPT_STRING_LIST('o', "push-option", &push_options, N_("server-specific"), N_("option to transmit")),

Here it seems to expect "-o". If we really want a short option, "-o" would probably be OK, as I do not think "git push" wants to have "send the output to this file" option.

Show 20 quoted lines
> diff --git a/send-pack.c b/send-pack.c
> index 299d303..c943560 100644
> --- a/send-pack.c
> +++ b/send-pack.c
> @@ -260,6 +260,7 @@ static int generate_push_cert(struct strbuf *req_buf,
>  			      const char *push_cert_nonce)
>  {
>  	const struct ref *ref;
> +	struct string_list_item *item;
>  	char *signing_key = xstrdup(get_signing_key());
>  	const char *cp, *np;
>  	struct strbuf cert = STRBUF_INIT;
> @@ -278,6 +279,12 @@ static int generate_push_cert(struct strbuf *req_buf,
>  		strbuf_addf(&cert, "nonce %s\n", push_cert_nonce);
>  	strbuf_addstr(&cert, "\n");
>  
> +	if (args->push_options) {
> +		for_each_string_list_item(item, args->push_options)
> +			strbuf_addf(&cert, "push-option %s\n", item->string);
> +		strbuf_addstr(&cert, "\n");
Why the extra blank?
I would actually have expected to see
	certificate version ...
        pusher ...
        <datestamp>
	pushee ...	# optional
        nonce ...	# optional
        push-option ... # optional
        push-option ... # optional
        <old> <new> <name>
        ...

by adding this between the two lines in the pre-context of this hunk, i.e.

	if (push_cert_nonce[0])
		strbuf_addf(&cert, "nonce %s\n", push_cert_nonce);
	if (args->push_options)
		for_each_string_list_item(item, args->push_options)
			strbuf_addf(&cert, "push-option %s\n", item->string);
	strbuf_addstr(&cert, "\n");
Previous: Stefan BellerNext: Stefan Beller
Message 21 of 31 in “[PATCHv3 0/4] Push options in C Git”
  1. Stefan BellerJul 7, 2016
  2. 2/4 receive-pack: implement advertising and receiving push optionsStefan Beller, Jul 7, 2016
  3. Junio C HamanoJul 7, 2016
  4. Stefan BellerJul 7, 2016
  5. Jeff KingJul 7, 2016
  6. Stefan BellerJul 7, 2016
  7. Jeff KingJul 7, 2016
  8. Junio C HamanoJul 7, 2016
  9. Jonathan NiederJul 8, 2016
  10. Junio C HamanoJul 8, 2016
  11. Stefan BellerJul 8, 2016
  12. Jeff KingJul 8, 2016
  13. Stefan BellerJul 8, 2016
  14. Jeff KingJul 8, 2016
  15. Stefan BellerJul 8, 2016
  16. Jeff KingJul 8, 2016
  17. Stefan BellerJul 8, 2016
  18. Jeff KingJul 8, 2016
  19. Stefan BellerJul 8, 2016
  20. 3/4 push: accept push optionsStefan Beller, Jul 7, 2016
  21. Junio C HamanoJul 7, 2016
  22. Stefan BellerJul 8, 2016
  23. Junio C HamanoJul 11, 2016
  24. 1/4 push options: {pre,post}-receive hook learns about push optionsStefan Beller, Jul 7, 2016
  25. Junio C HamanoJul 7, 2016
  26. Stefan BellerJul 7, 2016
  27. Junio C HamanoJul 7, 2016
  28. 4/4 add a test for push optionsStefan Beller, Jul 7, 2016
  29. Junio C HamanoJul 7, 2016
  30. Junio C HamanoJul 7, 2016
  31. Stefan BellerJul 7, 2016

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.