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

Re: [PATCH 2/8] p5400: add perf tests for git-receive-pack(1)

From
Jeff King <peff@peff.net>
Date
May 20, 2021, 17:04 UTC
Message-ID
<YKaWuYy+iz3qhBad@coredump.intra.peff.net>
In-Reply-To
<f248b41d6e2df2d34a4304e2655df8cb094483e9.1621451532.git.ps@pks.im>
On Wed, May 19, 2021 at 09:13:27PM +0200, Patrick Steinhardt wrote:
> +while read name repo
> +do
> +	refs=("create updated:new")

This (and the other array manipulation below) is a bash-ism. Presumably you've got TEST_SHELL_PATH pointed at bash. Without that, on a system where /bin/sh is dash, the script chokes here.

For your purposes here, I think you can get by with just a single string with newlines in it. Or even a file (see below).

Show 7 quoted lines
> +	while read desc ref
> +	do
> +		test_expect_success "setup $name $desc" "
> +			test_must_fail git push --force '$repo' '$ref' \
> +				--receive-pack='tee pack | git receive-pack' 2>err &&
> +			grep 'failed in pre-receive hook' err
> +		"

This inverts the double- and single- quotes from our usual style. So if $repo is "foo", you are creating a string that has:

  test_must_fail git push --force 'foo' ...

in it, and then the test harness will eval that string. That will fail if $repo itself contains a single quote. Pretty unlikely, but I think it contains the absolute path.

The usual style is:
  test_expect_success "setup $name $desc" '
	test_must_fail git push --force "$repo" "$ref" \
	...etc...
  '

where the variables are dereferenced inside the eval'd snippet. So no quoting is necessary, no matter what's in the variables.

> +		test_perf "receive-pack $name $desc" "
> +			git receive-pack '$repo' <pack >negotiation &&
> +			grep 'pre-receive hook declined' negotiation
> +		"

Likewise here, but note that test_perf is tricky! It runs the snippet in a sub-process. You have to export $repo to make it visible (you can use test_export, but you don't need to; there's some discussing in t/perf/README).

> +	done < <(printf "%s\n" "${refs[@]}")
> +done < <(printf "%s\n" "clone $TARGET_REPO_CLONE" "extrarefs $TARGET_REPO_REFS" "empty $TARGET_REPO_EMPTY")

These process substitutions are also bash-isms. I guess you're trying to avoid putting the while on the right-hand side of a pipe like:

  printf "%s\n" ... |
  while read ...

which is good, because they set variables and those values don't reliably make it out of the pipeline. If you stick the contents of $refs into a file, then you can just do:

  while read ...
  do
     ...
  done <ref-descs
For the outer one, a here-doc is probably a bit simpler:
  while read ...
  do
     ...
  done <<-EOF
  clone $TARGET_REPO_CLONE
  extrarefs $TARGET_REPO_REFS
  empty $TARGET_REPO_EMPTY
  EOF
-Peff
Previous: Chris TorekNext: SZEDER Gábor
Message 6 of 22 in “Speed up connectivity checks via quarantine dir”
  1. 0/8 Speed up connectivity checks via quarantine dirPatrick Steinhardt, May 19, 2021
  2. 1/8 perf: fix when running with TEST_OUTPUT_DIRECTORYPatrick Steinhardt, May 19, 2021
  3. Chris TorekMay 20, 2021
  4. 2/8 p5400: add perf tests for git-receive-pack(1)Patrick Steinhardt, May 19, 2021
  5. Chris TorekMay 20, 2021
  6. Jeff KingMay 20, 2021
  7. SZEDER GáborMay 21, 2021
  8. 3/8 tmp-objdir: expose function to retrieve pathPatrick Steinhardt, May 19, 2021
  9. Elijah NewrenMay 20, 2021
  10. 4/8 packfile: have `for_each_file_in_pack_dir()` return error codesPatrick Steinhardt, May 19, 2021
  11. 5/8 object-file: allow reading loose objects without reading their contentsPatrick Steinhardt, May 19, 2021
  12. 6/8 connected: implement connectivity check via temporary object dirsPatrick Steinhardt, May 19, 2021
  13. 7/8 receive-pack: skip connectivity checks on delete-only commandsPatrick Steinhardt, May 19, 2021
  14. Felipe ContrerasMay 21, 2021
  15. Jeff KingMay 27, 2021
  16. 8/8 receive-pack: check connectivity via quarantined objectsPatrick Steinhardt, May 19, 2021
  17. Chris TorekMay 20, 2021
  18. Jeff KingMay 20, 2021
  19. Junio C HamanoMay 20, 2021
  20. Jeff KingMay 21, 2021
  21. Patrick SteinhardtMay 21, 2021
  22. Ævar Arnfjörð BjarmasonMay 21, 2021

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.