Re: git rebase exec make -C in worktree confuses repo root dir

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Oct 14, 2024 at 5:19 PM Taylor Blau <me@xxxxxxxxxxxx> wrote:
> On Mon, Oct 14, 2024 at 10:46:45PM +0200, David Moberg wrote:
> > 1. This command should return the worktree toplevel, not a subdirectory
> >   $ git rev-parse --show-toplevel
> >   /tmp/tmp.DUUAVQCIKe/repo2
> >
> > 2. And the git grep command should return the match from dir/Makefile,
> > not Fatal Error
> >   $ git grep banana
> >   Makefile:       git grep "banana" -- "$$BANANA"
>
> I am not sure if this is expected behavior or not, but it feels
> unintentional to me. Perhaps I am missing something funky in your
> example that is causing it to behave this way.

This looks like unintentional behavior; probably a bug. It seems to be
triggered by `git rebase -i` setting GIT_DIR. Here's an even simpler
reproduction recipe:

    % git init foo
    % cd foo
    % mkdir dir
    % echo foo >dir/file
    % git add dir/file
    % git commit -m foo
    % git worktree add ../bar
    % cd ../bar
    % git -C dir rev-parse --show-toplevel
    /.../bar
    % GIT_DIR=../../foo/.git/worktrees/bar \
        git -C dir rev-parse --show-toplevel
    /.../bar/dir

The `git rev-parse --show-toplevel` invocation with GIT_DIR set is
incorrectly returning `/.../bar/dir` rather than `/.../bar`.





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux