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
SZEDER Gábor <szeder.dev@gmail.com>
Date
Nov 3, 2020, 10:23 UTC
Message-ID
<20201103102307.GI24813@szeder.dev>
In-Reply-To
<148e39960a2185d2355cdfe34f8856e708fb1b80.1604362701.git.jonathantanmy@google.com>
On Mon, Nov 02, 2020 at 04:26:11PM -0800, Jonathan Tan wrote:
Show 45 quoted lines
> diff --git a/t/t5700-protocol-v1.sh b/t/t5700-protocol-v1.sh
> index 022901b9eb..22459d37f5 100755
> --- a/t/t5700-protocol-v1.sh
> +++ b/t/t5700-protocol-v1.sh
> @@ -146,6 +146,56 @@ test_expect_success 'push with file:// using protocol v1' '
>  	grep "push< version 1" log
>  '
>  
> +test_expect_success 'push with file:// using protocol v1 and --base' '
> +	test_commit -C file_child four &&
> +	COMMON_HASH=$(git -C file_child rev-parse three) &&
> +
> +	# Push to another branch, as the target repository has the
> +	# master branch checked out and we cannot push into it.
> +	GIT_TRACE_PACKET=1 git -C file_child -c protocol.version=1 \
> +		push --base=three origin HEAD:client_branch_four 2>log &&
> +
> +	# Server responded using protocol v1
> +	grep "push< version 1" log &&
> +	# Server advertised only the expected object
> +	grep "$COMMON_HASH .have" log
> +'
> +
> +test_expect_success 'push with file:// using protocol v0 and --base' '
> +	test_commit -C file_child five &&
> +	COMMON_HASH=$(git -C file_child rev-parse four) &&
> +
> +	# Push to another branch, as the target repository has the
> +	# master branch checked out and we cannot push into it.
> +	GIT_TRACE_PACKET=1 git -C file_child -c protocol.version=0 \
> +		push --base=four origin HEAD:client_branch_five 2>log &&
> +
> +	# Server did not respond with any version
> +	! grep "push< version" log &&
> +	# Server advertised only the expected object
> +	grep "$COMMON_HASH .have" log
> +'
> +
> +test_expect_success 'push with invalid --base' '
> +	test_commit -C file_child six &&
> +
> +	# Server does not have "six".
> +	test_must_fail git -C file_child -c protocol.version=0 \
> +		push --base=an_invalid_object origin HEAD:client_branch_six 2>log &&
> +	grep "is not a valid object" log
This should rather use 'test_i18ngrep' ...
Show 16 quoted lines
> +'
> +
> +test_expect_success 'push with --base that does not exist on server' '
> +	COMMON_HASH=$(git -C file_child rev-parse six) &&
> +
> +	# The push still succeeds.
> +	GIT_TRACE_PACKET=1 git -C file_child -c protocol.version=0 \
> +		push --base=six origin HEAD:client_branch_six 2>log &&
> +
> +	# Server did not advertise "six", since it does not know it
> +	! grep "$COMMON_HASH .have" log
> +'
> +
>  # Test protocol v1 with 'ssh://' transport
>  #
>  test_expect_success 'setup ssh wrapper' '
Show 11 quoted lines
> diff --git a/transport.c b/transport.c
> index ffe2115845..531ca0a834 100644
> --- a/transport.c
> +++ b/transport.c
> @@ -236,6 +236,10 @@ static int set_git_option(struct git_transport_options *opts,
>  		list_objects_filter_die_if_populated(&opts->filter_options);
>  		parse_list_objects_filter(&opts->filter_options, value);
>  		return 0;
> +	} else if (!strcmp(name, TRANS_OPT_PUSH_BASE)) {
> +		if (get_oid(value, &opts->push_base))
> +			die(_("transport: '%s' is not a valid object"), value);
... because the error message here is translated.
> +		return 0;
>  	}
>  	return 1;
>  }
Previous: Jonathan TanNext: Junio C Hamano
Message 4 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.