Skip to content

Commit 91de27c

Browse files
avargitster
authored andcommitted
perf: add function to setup a fresh test repo
Add a function to setup a fresh test repo via 'git init' to compliment the existing functions to copy over a normal & large repo. Some performance tests don't need any existing repository data at all to be significant, e.g. tests which stress glob matches against single pathological revisions or files, which I'm about to add in a subsequent commit. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent b06d364 commit 91de27c

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

t/perf/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ sources perf-lib.sh:
106106

107107
After that you will want to use some of the following:
108108

109+
test_perf_fresh_repo # sets up an empty repository
109110
test_perf_default_repo # sets up a "normal" repository
110111
test_perf_large_repo # sets up a "large" repository
111112

t/perf/perf-lib.sh

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ if test -z "$GIT_PERF_LARGE_REPO"; then
7878
GIT_PERF_LARGE_REPO=$TEST_DIRECTORY/..
7979
fi
8080

81+
test_perf_do_repo_symlink_config_ () {
82+
test_have_prereq SYMLINKS || git config core.symlinks false
83+
}
84+
8185
test_perf_create_repo_from () {
8286
test "$#" = 2 ||
8387
error "bug in the test script: not 2 parameters to test-create-repo"
@@ -102,15 +106,22 @@ test_perf_create_repo_from () {
102106
) &&
103107
(
104108
cd "$repo" &&
105-
"$MODERN_GIT" init -q && {
106-
test_have_prereq SYMLINKS ||
107-
git config core.symlinks false
108-
} &&
109+
"$MODERN_GIT" init -q &&
110+
test_perf_do_repo_symlink_config_ &&
109111
mv .git/hooks .git/hooks-disabled 2>/dev/null
110112
) || error "failed to copy repository '$source' to '$repo'"
111113
}
112114

113115
# call at least one of these to establish an appropriately-sized repository
116+
test_perf_fresh_repo () {
117+
repo="${1:-$TRASH_DIRECTORY}"
118+
"$MODERN_GIT" init -q "$repo" &&
119+
(
120+
cd "$repo" &&
121+
test_perf_do_repo_symlink_config_
122+
)
123+
}
124+
114125
test_perf_default_repo () {
115126
test_perf_create_repo_from "${1:-$TRASH_DIRECTORY}" "$GIT_PERF_REPO"
116127
}

0 commit comments

Comments
 (0)