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

[PATCH v2 2/3] p9210: fix 'scalar clone' when running from a detached HEAD

From
Philippe Blain via GitGitGadget <gitgitgadget@gmail.com>
Date
Apr 12, 2025, 18:15 UTC
Message-ID
<1092c32609f249839453052ca802cb10256cb48f.1744481732.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1936.v2.git.git.1744481732.gitgitgadget@gmail.com>
From: Philippe Blain <levraiphilippeblain@gmail.com>

In p9210-scalar-clone.sh, we test using 'scalar clone' to clone $GIT_PERF_LARGE_REPO (copied locally as 'to-clone'), which defaults to the git.git checkout we are running the test from.

When --branch is not specified (as in this test), 'scalar clone' tries to get the default branch of the remote repository by parsing the output of 'git ls-remote --symref $URL HEAD', as implemented in scalar.c:remote_default_branch. When the git.git checkout we are running the test from is in detached HEAD, this fails and we fall back to using the name of the currently checked out branch in the newly initialized repository, which in this case is the value returned earlier in cmd_clone by repo_default_branch_name.

We then invoke 'git checkout -t origin/$branch', with $branch being the name we got from remote_default_branch. This invocation fails if '$branch' does not exist as a branch in the current git.git checkout.

Fix this by creating a local branch in 'to-clone' in the setup test "enable server-side partial clone", making sure to use '-B' in case a branch named 'test-branch' already exists.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
---
 t/perf/p9210-scalar.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/t/perf/p9210-scalar.sh b/t/perf/p9210-scalar.sh
index 265f7cd1fe2..56b075e906e 100755
--- a/t/perf/p9210-scalar.sh
+++ b/t/perf/p9210-scalar.sh
@@ -7,7 +7,8 @@ test_perf_large_repo "$TRASH_DIRECTORY/to-clone"
 
 test_expect_success 'enable server-side partial clone' '
 	git -C to-clone config uploadpack.allowFilter true &&
-	git -C to-clone config uploadpack.allowAnySHA1InWant true
+	git -C to-clone config uploadpack.allowAnySHA1InWant true &&
+	git -C to-clone checkout -B test-branch
 '
 
 test_perf 'scalar clone' '
-- 
gitgitgadget
Previous: Philippe Blain via GitGitGadgetNext: Philippe Blain via GitGitGadget
Message 9 of 13 in “Two perf test fixes”
  1. 0/2 Two perf test fixesPhilippe Blain via GitGitGadget, Mar 28, 2025
  2. 1/2 p7821: fix test_perf invocation for prereqsPhilippe Blain via GitGitGadget, Mar 28, 2025
  3. Patrick SteinhardtMar 31, 2025
  4. Philippe BlainApr 13, 2025
  5. 2/2 p9210: fix 'scalar clone' when running from a detached HEADPhilippe Blain via GitGitGadget, Mar 28, 2025
  6. Patrick SteinhardtMar 31, 2025
  7. 0/3 Two perf test fixesPhilippe Blain via GitGitGadget, Apr 12, 2025
  8. 1/3 p7821: fix test_perf invocation for prereqsPhilippe Blain via GitGitGadget, Apr 12, 2025
  9. 2/3 p9210: fix 'scalar clone' when running from a detached HEADPhilippe Blain via GitGitGadget, Apr 12, 2025
  10. 3/3 p7821: fix instructions for testing with threadsPhilippe Blain via GitGitGadget, Apr 12, 2025
  11. Junio C HamanoApr 14, 2025
  12. Philippe BlainApr 13, 2025
  13. Junio C HamanoApr 14, 2025

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.