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
Jeff King <peff@peff.net>
Date
Jun 4, 2026, 06:27 UTC
Message-ID
<20260604062720.GA3195904@coredump.intra.peff.net>
In-Reply-To
<ah6WEtk2pXyViEQA@pks.im>
On Tue, Jun 02, 2026 at 10:36:34AM +0200, Patrick Steinhardt wrote:
Show 19 quoted lines
> > 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.

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. :)

-Peff
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 5 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.