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.