Skip to content

Commit 7501b59

Browse files
dschogitster
authored andcommitted
perf: make the tests work in worktrees
This patch makes perf-lib.sh more robust so that it can run correctly even inside a worktree. For example, it assumed that $GIT_DIR/objects is the objects directory (which is not the case for worktrees) and it used the commondir file verbatim, even if it contained a relative path. Furthermore, the setup code expected `git rev-parse --git-dir` to spit out a relative path, which is also not true for worktrees. Let's just change the code to accept both relative and absolute paths, by avoiding the `cd` into the copied working directory. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fd9dbdf commit 7501b59

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

t/perf/perf-lib.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,22 @@ test_perf_create_repo_from () {
8080
error "bug in the test script: not 2 parameters to test-create-repo"
8181
repo="$1"
8282
source="$2"
83-
source_git=$source/$(cd "$source" && git rev-parse --git-dir)
83+
source_git="$(git -C "$source" rev-parse --git-dir)"
84+
objects_dir="$(git -C "$source" rev-parse --git-path objects)"
8485
mkdir -p "$repo/.git"
8586
(
86-
cd "$repo/.git" &&
87-
{ cp -Rl "$source_git/objects" . 2>/dev/null ||
88-
cp -R "$source_git/objects" .; } &&
87+
{ cp -Rl "$objects_dir" "$repo/.git/" 2>/dev/null ||
88+
cp -R "$objects_dir" "$repo/.git/"; } &&
8989
for stuff in "$source_git"/*; do
9090
case "$stuff" in
91-
*/objects|*/hooks|*/config)
91+
*/objects|*/hooks|*/config|*/commondir)
9292
;;
9393
*)
94-
cp -R "$stuff" . || exit 1
94+
cp -R "$stuff" "$repo/.git/" || exit 1
9595
;;
9696
esac
9797
done &&
98-
cd .. &&
98+
cd "$repo" &&
9999
git init -q && {
100100
test_have_prereq SYMLINKS ||
101101
git config core.symlinks false

0 commit comments

Comments
 (0)