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

Re: [PATCH 1/2] t5516-fetch-push: fix 'push with dry-run' test

From
Junio C Hamano <gitster@pobox.com>
Date
May 11, 2018, 03:32 UTC
Message-ID
<xmqqmux6hnop.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20180510140154.30381-1-szeder.dev@gmail.com>
SZEDER Gábor <szeder.dev@gmail.com> writes:
Show 8 quoted lines
> In a while-at-it cleanup replacing a 'cd dir && <...> && cd ..' with a
> subshell, commit 28391a80a9 (receive-pack: allow deletion of corrupt
> refs, 2007-11-29) also moved the assignment of the $old_commit
> variable to that subshell.  This variable, however, is used outside of
> that subshell as a parameter of check_push_result(), to check that a
> ref still points to the commit where it is supposed to.  With the
> variable remaining unset outside the subshell check_push_result()
> doesn't perform that check at all.
Sigh/Blush.  Thanks for finding an old screw-up.
Show 39 quoted lines
>
> Use 'git -C <dir> cmd...', so we don't need to change directory, and
> thus don't need the subshell either when setting $old_commit.
>
> Furthermore, change check_push_result() to require at least three
> parameters (the repo, the oid, and at least one ref), so it will catch
> similar issues earlier should they ever arise.
>
> Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
> ---
>  t/t5516-fetch-push.sh | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
> index 82239138d5..832b79ad40 100755
> --- a/t/t5516-fetch-push.sh
> +++ b/t/t5516-fetch-push.sh
> @@ -94,6 +94,9 @@ mk_child() {
>  }
>  
>  check_push_result () {
> +	test $# -ge 3 ||
> +	error "bug in the test script: check_push_result requires at least 3 parameters"
> +
>  	repo_name="$1"
>  	shift
>  
> @@ -553,10 +556,7 @@ test_expect_success 'branch.*.pushremote config order is irrelevant' '
>  test_expect_success 'push with dry-run' '
>  
>  	mk_test testrepo heads/master &&
> -	(
> -		cd testrepo &&
> -		old_commit=$(git show-ref -s --verify refs/heads/master)
> -	) &&
> +	old_commit=$(git -C testrepo show-ref -s --verify refs/heads/master) &&
>  	git push --dry-run testrepo : &&
>  	check_push_result testrepo $old_commit heads/master
>  '
Previous: SZEDER Gábor
Message 3 of 3 in “t5516-fetch-push: fix 'push with dry-run' test”
  1. 1/2 t5516-fetch-push: fix 'push with dry-run' testSZEDER Gábor, May 10, 2018
  2. 2/2 t5516-fetch-push: fix broken &&-chainSZEDER Gábor, May 10, 2018
  3. Junio C HamanoMay 11, 2018

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.