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 <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed May 13, 2016 at 15:25 UTC 7501b59210906c89747dca1c44e15d8c2214c01d
1 file changed +7 -7
t/perf/perf-lib.sh
+7 -7
@@ -80,22 +80,22 @@ test_perf_create_repo_from () {
80 error "bug in the test script: not 2 parameters to test-create-repo"
81 repo="$1"
82 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)"
85 mkdir -p "$repo/.git"
86 (
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/"; } &&
89 for stuff in "$source_git"/*; do
90 case "$stuff" in
91 - */objects|*/hooks|*/config)
91 + */objects|*/hooks|*/config|*/commondir)
92 ;;
93 *)
94 - cp -R "$stuff" . || exit 1
94 + cp -R "$stuff" "$repo/.git/" || exit 1
95 ;;
96 esac
97 done &&
98 - cd .. &&
98 + cd "$repo" &&
99 git init -q && {
100 test_have_prereq SYMLINKS ||
101 git config core.symlinks false