Subject: Re: [PATCH 2/2] git_path(): handle `.lock` files correctly

From: SZEDER Gábor <[email-masked]>
Date: Fri, 18 Oct 2019 13:06:18 +0200

On Fri, Oct 18, 2019 at 12:05:20AM +0200, Johannes Schindelin wrote:
> > I tried to reproduce this issue in a working tree, but
> > no matter what I've tried, 'git rev-parse --git-dir index.lock' always
> > returned the right path.
> 
> With `s/--git-dir/--git-path/`, I agree.

Right.  I mistyped it a few times on the command line as well, but
then the command's output reminded me that I messed up.  Alas, no such
reminder when writing the email...

> > On a related note, I'm not sure whether the path of the reflogs
> > directory is right while in a different working tree...  Both with and
> > without this patch I get a path pointing to the main working tree:
> >
> >   $ ./git -C WT/ rev-parse --git-path logs
> >   /home/szeder/src/git/.git/logs
> >
> > However, I'm not sure what the right path should be in the first
> > place, given that each working tree has its own 'logs' directory, but
> > only for HEAD's reflog, while everything else goes to the main working
> > tree's 'logs' directory.
> 
> It's like Junio said, the reflog for `HEAD` is special because `HEAD` is
> special. Look for `common_list` in `path.c` (it is a bit confusing, I
> admit, you have to look for the 3rd column of numbers: if it is a `1`,
> then it is a worktree-specific path, if it is `0`, it is supposed to
> live in the "commondir", i.e. in the gitdir of the main worktree).

OK, got it.

I didn't look yesterday at all, but now I did, and, unfortunately, see
two more bugs, and one of them is a "proper" bug leading to bogus
output:

  $ git -C WT/ rev-parse --git-path logs/refs --git-path logs/refs/
  /home/szeder/src/git/.git/logs/refs
  /home/szeder/src/git/.git/worktrees/WT/logs/refs/