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

Re: [PATCH] t/perf: handle worktrees as test repos

From
Jeff King <peff@peff.net>
Date
Feb 16, 2021, 21:38 UTC
Message-ID
<YCw7PcqLUFmLJj7K@coredump.intra.peff.net>
In-Reply-To
<nycvar.QRO.7.76.6.2102162211050.52@tvgsbejvaqbjf.bet>
On Tue, Feb 16, 2021 at 10:13:49PM +0100, Johannes Schindelin wrote:
Show 17 quoted lines
> I think you'll also need the equivalent of:
> 
> -- snip --
> diff --git a/t/perf/perf-lib.sh b/t/perf/perf-lib.sh
> index 22d727cef83..0949c360ec4 100644
> --- a/t/perf/perf-lib.sh
> +++ b/t/perf/perf-lib.sh
> @@ -84,7 +84,7 @@ test_perf_create_repo_from () {
>  			cp -R "$objects_dir" "$repo/.git/"; } &&
>  		for stuff in "$source_git"/*; do
>  			case "$stuff" in
> -				*/objects|*/hooks|*/config|*/commondir)
> +				*/objects|*/hooks|*/config|*/commondir|*/gitdir)
>  					;;
>  				*)
>  					cp -R "$stuff" "$repo/.git/" || exit 1
> -- snap --
I think that's reasonable to do, but isn't it orthogonal?

My patch is fixing the case that we do not copy enough files from a workdir.

Both before and after my patch, we'd be copying the gitdir file. I don't think it would actually cause a problem in practice, since a "gitdir" file in the main repo dir doesn't have any meaning. But I do think it's prudent to avoid copying it (just as we avoid commondir) to avoid any confusion, or commands accidentally touching the original repository.

Likewise...
Show 9 quoted lines
> > Having written that, it occurs to me that an even simpler solution is to
> > just always use the commondir as the source of the scratch repo. It does
> > not produce the same outcome, but the point is generally just to find a
> > suitable starting point for a repository. Grabbing the main repo instead
> > of one of its worktrees is probably OK for most tests.
> 
> Good point: we probably also need to exclude `*/worktrees/*`, but that is
> a bit trickier as we would not want to exclude, say,
> `refs/heads/worktrees/cleanup`.

Yes, for the same reason, I think we should exclude the whole worktrees directory. I don't think we have to worry about that case (and if we did, we'd already have trouble with "refs/heads/config" or similar). The reason is that the case statement is only looking at the glob made from the top-level. The actual recursive expansion of "refs/", etc, is done by "cp -R".

Anyway, what I'm suggesting is that it would be a separate patch to avoid looking at gitdir and worktrees, in order to increase overall safety. Do you want to do that on top, or should I?

-Peff
Previous: Johannes SchindelinNext: Jeff King
Message 7 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.