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

Junio C Hamano <[email protected]>
Newsgroups org.kernel.vger.git
Message-ID <[email protected]>
Junio C Hamano <[email protected]> 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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.