path: root/t/perf/
diff options
authorJeff King <>2021-02-26 07:13:15 (GMT)
committerJunio C Hamano <>2021-02-26 22:21:04 (GMT)
commit36e834abc169353f7df8c862cb19bc400c290dba (patch)
tree4e749ed83c12a21ada1463b4ba1ef201bef3d875 /t/perf/
parent85b87a5396667d9e4fa31219a64ade21c49ebc20 (diff)
t/perf: avoid copying worktree files from test repo
When running the perf suite, we copy files from an existing $GIT_DIR to a scratch repository to give us a realistic setup on which to operate. Since the perf scripts themselves may modify the scratch repository, we want to make sure we've scrubbed any references back to the original. One existing example is that we avoid copying the file "commondir" at the top-level of the repository. In a worktree git-dir (e.g., .git/worktrees/foo), that file contains the path to the parent repository; copying it could mean ref updates in the scratch repository affect the original. But there are other files we should cover, too: - "gitdir" in a worktree git-dir contains the path to the actual .git file in the working tree. We _shouldn't_ end up looking at it at all, since the lack of a "commondir" file means Git won't consider this to be a worktree git-dir. But it's best to err on the safe side. - in a parent repository that contains worktrees, the "$GIT_DIR/worktrees" directory will contain the git dirs for the individual worktrees. Which will themselves contain commondir and gitdir files that may reference the original repository. We should likewise remove them. Note that this does mean that the perf suite's scratch repositories will never have any worktrees. That's OK; we don't have any perf tests that are influenced by their presence. If we add any, they'd probably want to create the worktrees themselves anyway. This patch adds both paths to the set of omissions in test_perf_copy_repo_contents(). Note that we won't get confused here by matching arbitrary names like refs/heads/commondir. This list is always matching top-level entries in $GIT_DIR (we rely on "cp -R" to do the actual recursion). Suggested-by: Johannes Schindelin <> Signed-off-by: Jeff King <> Reviewed-by: Derrick Stolee <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 't/perf/')
1 files changed, 1 insertions, 1 deletions
diff --git a/t/perf/ b/t/perf/
index 1226be4..601d9f6 100644
--- a/t/perf/
+++ b/t/perf/
@@ -74,7 +74,7 @@ test_perf_copy_repo_contents () {
for stuff in "$1"/*
case "$stuff" in
- */objects|*/hooks|*/config|*/commondir)
+ */objects|*/hooks|*/config|*/commondir|*/gitdir|*/worktrees)
cp -R "$stuff" "$repo/.git/" || exit 1