git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Oct 15, 2024, 20:01 UTC
Message-ID
<CAPig+cQ6=HDD447xTHQ84hmsF3SMbC5nH_PXf3rZWvTWmp18ug@mail.gmail.com>
In-Reply-To
<CAL2+MivOu=_HYg+2KoMKMUtz+=q2jv-K9u9Zxrhe3OuHLCmwFA@mail.gmail.com>
On Tue, Oct 15, 2024 at 2:55 PM David Moberg <kaddkaka@gmail.com> wrote:
Show 24 quoted lines
> Den tis 15 okt. 2024 kl 09:11 skrev Eric Sunshine <sunshine@sunshineco.com>:
> > 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`.
>
> Thanks, that is indeed a much smaller example and it seems to exhibit
> the same issue. Can we figure out how to fix it?

Someone is going to have to dig into the code, but my Git time is very limited right now, so perhaps someone else can do the digging.

If you want an immediate workaround for the problem for your specific use-case, you can probably unset GIT_DIR in your `exec` instruction.

(By the way, please avoid top-posting when you reply on this list; instead, post inline as I did here.)

Previous: David MobergNext: Phillip Wood
Message 6 of 11 in “git rebase exec make -C in worktree confuses repo root dir”
  1. David MobergOct 14, 2024
  2. Taylor BlauOct 14, 2024
  3. David MobergOct 14, 2024
  4. Eric SunshineOct 15, 2024
  5. David MobergOct 15, 2024
  6. Eric SunshineOct 15, 2024
  7. Phillip WoodOct 16, 2024
  8. Taylor BlauOct 16, 2024
  9. Elijah NewrenOct 17, 2024
  10. Eric SunshineOct 16, 2024
  11. phillip.wood123@gmail.comNov 5, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.