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

Re: [PATCH v2 1/1] fsck: ignore missing "refs" directory for linked worktrees

From
shejialuo <shejialuo@gmail.com>
Date
Jun 2, 2025, 14:11 UTC
Message-ID
<aD2xC0YBDm4TASHG@ArchLinux>
In-Reply-To
<21461585-273f-46a9-a750-6ae7b414fcdc@app.fastmail.com>
On Mon, Jun 02, 2025 at 03:59:01PM +0200, Kristoffer Haugsbakk wrote:
Show 14 quoted lines
> > +test_expect_success 'no refs directory of worktree should not cause problems' '
> > +	test_when_finished "rm -rf repo" &&
> > +	git init repo &&
> > +	(
> > +		cd repo &&
> > +		test_commit initial &&
> > +		git worktree add --detach ./worktree &&
> > +
> > +		cd worktree &&
> 
> Now in this version you change-directory into `worktree`.  You would
> need a new subshell for that (test style).  But I don’t see the need to
> chdir in the first place?
> 

We should change directory into the `worktree`. This is because now in the test, we use "git rev-parse --git-dir" to get the git directory. We need to find `gitdir` of the linked worktree but not the `gitdir` of the main worktree. If we do not cd into the directory, we would get the `gitdir` of the main worktree.

And I agree with you that we need to spawn a subshell. Let me update the code. Thanks for reminding me, I forgot about that.

Show 16 quoted lines
> > +		worktree_refdir="$(git rev-parse --git-dir)/refs" &&
> > +		# Simulate old directory layout
> > +		rmdir "$worktree_refdir" &&
> > +		git refs verify 2>err &&
> > +		test_must_be_empty err
> > +	)
> > +'
> > +
> >  test_expect_success 'ref name check should work for multiple worktrees' '
> >  	test_when_finished "rm -rf repo" &&
> >  	git init repo &&
> > --
> > 2.49.0
> 
> The test passes for me.  Also when applying only the test (and not the
> fix) the test fails as expected.  Good.
Thanks for the feedback.
Jialuo
Previous: Kristoffer HaugsbakkNext: shejialuo
Message 18 of 21 in “[BUG] refs: verify does not work if there are v2.43.0 or older worktrees w/o wt. refs”
  1. kristofferhaugsbakk@fastmail.comMay 30, 2025
  2. Eric SunshineMay 30, 2025
  3. shejialuoMay 31, 2025
  4. Kristoffer HaugsbakkMay 31, 2025
  5. fsck: ignore missing "refs" directory for linked worktreesshejialuo, May 31, 2025
  6. Kristoffer HaugsbakkMay 31, 2025
  7. Junio C HamanoJun 2, 2025
  8. shejialuoJun 2, 2025
  9. Phillip WoodJun 2, 2025
  10. Patrick SteinhardtJun 2, 2025
  11. phillip.wood123@gmail.comJun 2, 2025
  12. Junio C HamanoJun 2, 2025
  13. shejialuoJun 2, 2025
  14. shejialuoJun 2, 2025
  15. 0/1 [BUG] refs: verify does not work if there are v2.43.0 or older worktrees w/o wt. refsshejialuo, Jun 2, 2025
  16. 1/1 fsck: ignore missing "refs" directory for linked worktreesshejialuo, Jun 2, 2025
  17. Kristoffer HaugsbakkJun 2, 2025
  18. shejialuoJun 2, 2025
  19. 0/1 [BUG] refs: verify does not work if there are v2.43.0 or older worktrees w/o wt. refsshejialuo, Jun 2, 2025
  20. 1/1 fsck: ignore missing "refs" directory for linked worktreesshejialuo, Jun 2, 2025
  21. Kristoffer HaugsbakkJun 2, 2025

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.