git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 2/2] t/perf: avoid copying worktree files from test repo

From
Jeff King <peff@peff.net>
Date
Feb 26, 2021, 07:13 UTC
Message-ID
<YDifi8YeJCcx0FaV@coredump.intra.peff.net>
In-Reply-To
<YDiesofYW18Mzd9Q@coredump.intra.peff.net>

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 <Johannes.Schindelin@gmx.de>
Signed-off-by: Jeff King <peff@peff.net>
---
 t/perf/perf-lib.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/perf/perf-lib.sh b/t/perf/perf-lib.sh
index 1226be4005..601d9f67dd 100644
--- a/t/perf/perf-lib.sh
+++ b/t/perf/perf-lib.sh
@@ -74,7 +74,7 @@ test_perf_copy_repo_contents () {
 	for stuff in "$1"/*
 	do
 		case "$stuff" in
-		*/objects|*/hooks|*/config|*/commondir)
+		*/objects|*/hooks|*/config|*/commondir|*/gitdir|*/worktrees)
 			;;
 		*)
 			cp -R "$stuff" "$repo/.git/" || exit 1
-- 
2.31.0.rc0.520.ge7c5201139
Previous: Jeff KingNext: Derrick Stolee
Message 10 of 12 in “t/perf: handle worktrees as test repos”
  1. t/perf: handle worktrees as test reposJeff King, Feb 16, 2021
  2. Jeff KingFeb 16, 2021
  3. Derrick StoleeFeb 16, 2021
  4. Junio C HamanoFeb 16, 2021
  5. Jeff KingFeb 16, 2021
  6. Johannes SchindelinFeb 16, 2021
  7. Jeff KingFeb 16, 2021
  8. t/perf worktree improvementsJeff King, Feb 26, 2021
  9. 1/2 t/perf: handle worktrees as test reposJeff King, Feb 26, 2021
  10. 2/2 t/perf: avoid copying worktree files from test repoJeff King, Feb 26, 2021
  11. Derrick StoleeFeb 26, 2021
  12. Johannes SchindelinMar 1, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.