Skip to content

Commit 3d358ad

Browse files
phil-blaingitster
authored andcommitted
p9210: fix 'scalar clone' when running from a detached HEAD
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d17cd97 commit 3d358ad

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

t/perf/p9210-scalar.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ test_perf_large_repo "$TRASH_DIRECTORY/to-clone"
77

88
test_expect_success 'enable server-side partial clone' '
99
git -C to-clone config uploadpack.allowFilter true &&
10-
git -C to-clone config uploadpack.allowAnySHA1InWant true
10+
git -C to-clone config uploadpack.allowAnySHA1InWant true &&
11+
git -C to-clone checkout -B test-branch
1112
'
1213

1314
test_perf 'scalar clone' '

0 commit comments

Comments
 (0)