Merge branch 'jk/perf-in-worktrees'

Perf test update to work better in secondary worktrees.

* jk/perf-in-worktrees:
  t/perf: avoid copying worktree files from test repo
  t/perf: handle worktrees as test repos
maint
Junio C Hamano 2021-03-22 14:00:23 -07:00
commit e8d5a423ca
1 changed files with 22 additions and 9 deletions

View File

@ -70,6 +70,19 @@ test_perf_do_repo_symlink_config_ () {
test_have_prereq SYMLINKS || git config core.symlinks false test_have_prereq SYMLINKS || git config core.symlinks false
} }


test_perf_copy_repo_contents () {
for stuff in "$1"/*
do
case "$stuff" in
*/objects|*/hooks|*/config|*/commondir|*/gitdir|*/worktrees)
;;
*)
cp -R "$stuff" "$repo/.git/" || exit 1
;;
esac
done
}

test_perf_create_repo_from () { test_perf_create_repo_from () {
test "$#" = 2 || test "$#" = 2 ||
BUG "not 2 parameters to test-create-repo" BUG "not 2 parameters to test-create-repo"
@ -77,20 +90,20 @@ test_perf_create_repo_from () {
source="$2" source="$2"
source_git="$("$MODERN_GIT" -C "$source" rev-parse --git-dir)" source_git="$("$MODERN_GIT" -C "$source" rev-parse --git-dir)"
objects_dir="$("$MODERN_GIT" -C "$source" rev-parse --git-path objects)" objects_dir="$("$MODERN_GIT" -C "$source" rev-parse --git-path objects)"
common_dir="$("$MODERN_GIT" -C "$source" rev-parse --git-common-dir)"
mkdir -p "$repo/.git" mkdir -p "$repo/.git"
( (
cd "$source" && cd "$source" &&
{ cp -Rl "$objects_dir" "$repo/.git/" 2>/dev/null || { cp -Rl "$objects_dir" "$repo/.git/" 2>/dev/null ||
cp -R "$objects_dir" "$repo/.git/"; } && cp -R "$objects_dir" "$repo/.git/"; } &&
for stuff in "$source_git"/*; do
case "$stuff" in # common_dir must come first here, since we want source_git to
*/objects|*/hooks|*/config|*/commondir) # take precedence and overwrite any overlapping files
;; test_perf_copy_repo_contents "$common_dir"
*) if test "$source_git" != "$common_dir"
cp -R "$stuff" "$repo/.git/" || exit 1 then
;; test_perf_copy_repo_contents "$source_git"
esac fi
done
) && ) &&
( (
cd "$repo" && cd "$repo" &&