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

Re: [PATCH v3] worktree repair: detect relative path in .git file correctly

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 21, 2026, 22:20 UTC
Message-ID
<xmqq4ignyv1z.fsf@gitster.g>
In-Reply-To
<xmqq8q5zyvwd.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 16 quoted lines
> Among these three, the last one obviously belongs here.  Leaving the
> relative path relative was the reason why we wanted to add
> read_gitfile_raw() in the first place.
>
> But moving the other two to here is a bit iffy.  The worktree repair
> job used to call read_gitfile_gently(), which means it used to
> depend on what the first two did for it, namely, to make the
> relative path after "gitdir:" from the .git file relative to the
> current process to make it usable, and to ensure that the directory
> pointed at by .git is indeed a git directory.  Is it correct to drop
> these from the caller, which now calls read_gitfile_raw() instead?
>
> IOW, I am not sure if the two functions are split correctly.  I
> expected that the only two things read_gitfile_gently() would do
> after read_gitfile_raw() are (1) upon error, jump to cleanup_return,
> and (2) otherwise call strbuf_realpath().

Actually, I take half of that back. If we pretend the leading part of the "path", which could be absolute, the result will lose the relative-ness of the original. Keeping the tweaking of the relative path in read_gitfile_gently() is reasonable. As is_git_directory() needs to be called on a usable path, if the relative path tweaking cannot be done inside read_gitfile_raw(), it cannot check if the directory is is_git_directory(), either.

So, the change to setup.c is fine as is. I didn't look at the changes to worktree.c, though.

Thanks.
Previous: Junio C HamanoNext: Yoichi Nakayama
Message 8 of 12 in “worktree repair: detect relative path in .git file correctly”
  1. worktree repair: detect relative path in .git file correctlyYoichi NAKAYAMA via GitGitGadget, Aug 15, 2026
  2. Junio C HamanoAug 17, 2026
  3. Yoichi NakayamaAug 17, 2026
  4. worktree repair: detect relative path in .git file correctlyYoichi NAKAYAMA via GitGitGadget, Aug 20, 2026
  5. Junio C HamanoAug 21, 2026
  6. worktree repair: detect relative path in .git file correctlyYoichi NAKAYAMA via GitGitGadget, Aug 21, 2026
  7. Junio C HamanoAug 21, 2026
  8. Junio C HamanoAug 21, 2026
  9. Yoichi NakayamaAug 27, 2026
  10. Junio C HamanoAug 27, 2026
  11. worktree repair: detect relative path in .git file correctlyYoichi NAKAYAMA via GitGitGadget, Aug 28, 2026
  12. Junio C HamanoAug 28, 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.