Thread (12 messages) flat view 12 messages, 3 authors, 16d ago

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

From: Junio C Hamano <hidden>
Date: 2026-08-21 22:20:58

Junio C Hamano [off-list ref] writes:
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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help