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

Re: [PATCH 2/4] push: teach --base for ssh:// and file://

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 8, 2020, 19:30 UTC
Message-ID
<xmqq4klzejdv.fsf@gitster.c.googlers.com>
In-Reply-To
<148e39960a2185d2355cdfe34f8856e708fb1b80.1604362701.git.jonathantanmy@google.com>
Jonathan Tan <jonathantanmy@google.com> writes:
Show 26 quoted lines
>  static int do_push(int flags,
>  		   const struct string_list *push_options,
> -		   struct remote *remote)
> +		   struct remote *remote,
> +		   const char *push_base)
>  {
>  	int i, errs;
>  	const char **url;
> @@ -405,6 +406,8 @@ static int do_push(int flags,
>  				transport_get(remote, url[i]);
>  			if (flags & TRANSPORT_PUSH_OPTIONS)
>  				transport->push_options = push_options;
> +			if (push_base)
> +				transport_set_option(transport, TRANS_OPT_PUSH_BASE, push_base);
>  			if (push_with_options(transport, push_refspec, flags))
>  				errs++;
>  		}
> @@ -413,6 +416,8 @@ static int do_push(int flags,
>  			transport_get(remote, NULL);
>  		if (flags & TRANSPORT_PUSH_OPTIONS)
>  			transport->push_options = push_options;
> +		if (push_base)
> +			transport_set_option(transport, TRANS_OPT_PUSH_BASE, push_base);
>  		if (push_with_options(transport, push_refspec, flags))
>  			errs++;
>  	}
These just send push_base as-is.
Show 16 quoted lines
> @@ -526,6 +531,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
>  	struct string_list *push_options;
>  	const struct string_list_item *item;
>  	struct remote *remote;
> +	const char *push_base = NULL;
>  
>  	struct option options[] = {
>  		OPT__VERBOSITY(&verbosity),
> @@ -562,6 +568,8 @@ int cmd_push(int argc, const char **argv, const char *prefix)
>  				TRANSPORT_FAMILY_IPV4),
>  		OPT_SET_INT('6', "ipv6", &family, N_("use IPv6 addresses only"),
>  				TRANSPORT_FAMILY_IPV6),
> +		OPT_STRING(0, "base", &push_base, N_("revision"),
> +			   N_("ancestor of commits to be pushed that is believed to be known by the server")),
>  		OPT_END()
>  	};

And this takes push_base as a string that is not even validated for any constraints.

Show 6 quoted lines
> @@ -629,7 +637,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
>  		if (strchr(item->string, '\n'))
>  			die(_("push options must not have new line characters"));
>  
> -	rc = do_push(flags, push_options, remote);
> +	rc = do_push(flags, push_options, remote, push_base);

And passes that arbitrary cruft given by the user down to the transport.

As the spirit of the "base" parameter is to tell the other side that it is what the receiving end believes to be common, shouldn't we make sure we do have it on our side after getting it from the user with OPT_STRING() before passing it down to the transport layer and have the transport layer convert it to an object name? This patch assumes that running get_oid_hex() at the transport layer and assuming that the transport would keep working on the_repository (hence when we say "We expect that the receiving end has 'master'", the transport somehow knows that is 'master' in our repository, not in a submodule repository, for example), but by converting it to full object name early, we do not have to assume transport to stay that way.

Previous: Derrick StoleeNext: Jonathan Tan
Message 7 of 21 in “"Push" protocol change proposal: user-specified base”
  1. 0/4 "Push" protocol change proposal: user-specified baseJonathan Tan, Nov 3, 2020
  2. 1/4 connect: refactor building of Extra ParametersJonathan Tan, Nov 3, 2020
  3. 2/4 push: teach --base for ssh:// and file://Jonathan Tan, Nov 3, 2020
  4. SZEDER GáborNov 3, 2020
  5. Junio C HamanoNov 8, 2020
  6. Derrick StoleeNov 3, 2020
  7. Junio C HamanoNov 8, 2020
  8. 3/4 remote-curl: teach --base for http(s)://Jonathan Tan, Nov 3, 2020
  9. Junio C HamanoNov 3, 2020
  10. 4/4 Doc: push with --baseJonathan Tan, Nov 3, 2020
  11. Jonathan NiederNov 3, 2020
  12. Jeff KingNov 3, 2020
  13. Junio C HamanoNov 3, 2020
  14. Jonathan TanNov 9, 2020
  15. Derrick StoleeNov 9, 2020
  16. Jonathan TanNov 9, 2020
  17. Junio C HamanoNov 9, 2020
  18. Jeff KingNov 9, 2020
  19. Jonathan TanNov 9, 2020
  20. Derrick StoleeNov 3, 2020
  21. Junio C HamanoNov 3, 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.