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

Re: [PATCH] read_gitfile_gently(): return non-repo path on error

From
Patrick Steinhardt <ps@pks.im>
Date
Jun 4, 2026, 07:08 UTC
Message-ID
<aiEkgBZJjmntRdNt@pks.im>
In-Reply-To
<20260604062720.GA3195904@coredump.intra.peff.net>
On Thu, Jun 04, 2026 at 02:27:20AM -0400, Jeff King wrote:
Show 26 quoted lines
> On Tue, Jun 02, 2026 at 10:36:34AM +0200, Patrick Steinhardt wrote:
> 
> > > The correct output (which this patch produces) is:
> > > 
> > >   fatal: not a git repository: /home/peff/compile/git/.git/worktrees/worktree3
> > > 
> > > And indeed, that path is missing. But why? I feel like I've run into
> > > this same problem occasionally over the last year or so, but never
> > > before. Did we get more aggressive about removing worktrees at some
> > > point? I haven't been able to reproduce whatever is killing off the
> > > worktree directory, and by the time I see the error it is long gone.
> > 
> > Both git-gc(1) and git-maintenance(1) prune orphaned worktrees that are
> > older than three months by default, which can be configured via
> > "gc.worktreePruneExpire". That logic has changed in 4dda60c9df (Merge
> > branch 'ps/maintenance-missing-tasks', 2025-05-15), which would kind of
> > match your timeline.
> > 
> > But rereading that patch series I cannot really see how it could result
> > in more aggressive pruning of worktrees. We used `git worktree prune
> > --expire <expiry>` before that series, and we still use that logic now.
> 
> Yeah, but this .git/worktrees/ directory shouldn't be pruned _at all_.
> The worktree itself is still there (which is why I'm getting the error).
> So perhaps there's a bug in checking that things are still there, or
> perhaps something is corrupting .git/worktrees/*/gitdir.
Oh, that sounds somewhat scary.
Show 11 quoted lines
> Another option is "I moved my git checkout and the worktree prune
> couldn't find the directory as an absolute path", but I'm sure I didn't
> do that.
> 
> An even more exotic option is that I run Git's test suite a lot, and
> very occasionally bugs in the test suite cause the script to escape the
> trash directory. And some scripts do run "rm -r .git/worktrees". I find
> it pretty unlikely for that to be the culprit though.
> 
> Oh well. I don't have any good leads, so I guess I'll see if it happens
> again. But maybe now if somebody else sees it we can commiserate. :)
I'll certainly be on the watchout.
Patrick
Previous: Jeff KingNext: Junio C Hamano
Message 6 of 12 in “read_gitfile_gently(): return non-repo path on error”
  1. read_gitfile_gently(): return non-repo path on errorJeff King, Jun 2, 2026
  2. Junio C HamanoJun 2, 2026
  3. Jeff KingJun 2, 2026
  4. Patrick SteinhardtJun 2, 2026
  5. Jeff KingJun 4, 2026
  6. Patrick SteinhardtJun 4, 2026
  7. Junio C HamanoJun 10, 2026
  8. read_gitfile(): simplify NOT_A_REPO error messageJeff King, Jun 16, 2026
  9. read_gitfile(): simplify NOT_A_REPO error messageJeff King, Jun 16, 2026
  10. Junio C HamanoJun 16, 2026
  11. Jeff KingJun 16, 2026
  12. Junio C HamanoJun 16, 2026

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.