git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git rebase exec make -C in worktree confuses repo root dir
@ 2024-10-14 20:46 David Moberg
  2024-10-14 21:19 ` Taylor Blau
  0 siblings, 1 reply; 12+ messages in thread
From: David Moberg @ 2024-10-14 20:46 UTC (permalink / raw)
  To: git@vger.kernel.org

Hi, I tried to minimize this but I haven't been able to come to a much
smaller example.

/David "kaddkaka" Moberg

What did you do before the bug happened? (Steps to reproduce your issue)

When doing `git rebase --exec` in a "secondary" worktree, it seems
that there is confusion about
where the repo root dir is. This sequence of commands can be run to reproduce:

  mktemp -d /tmp/git_bugreport_rebase_exec_worktree_root.XXXXXX
  cd /tmp/git_bugreport_rebase_exec_worktree_root.*
  mkdir repo
  cd repo/
  mkdir dir
  echo -e 'lint:' > dir/Makefile
  echo -e '\tgit rev-parse --show-toplevel' >> dir/Makefile
  echo -e '\tgit grep "banana" -- "$$BANANA"' >> dir/Makefile
  git init
  git add dir
  git commit -m"Intial commit"
  git worktree add ../repo2
  cd ../repo2/
  BANANA=$PWD GIT_EDITOR='sed -i "1s/noop/exec make -C dir\/ lint/"'
git rebase -i HEAD

What did you expect to happen? (Expected behavior)

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"

What happened instead? (Actual behavior)

1. --show-toplevel reports a subdirectory instead of toplevel:
  $ git rev-parse --show-toplevel
  /tmp/tmp.DUUAVQCIKe/repo2/dir
2. git grep complains that the pathspec is outside the repository with
fatal error:
  $ git grep "banana" -- "$BANANA"
  fatal: /tmp/tmp.DUUAVQCIKe/repo2: '/tmp/tmp.DUUAVQCIKe/repo2' is
outside repository at '/tmp/tmp.DUUAVQCIKe/repo2/dir'
  make: *** [Makefile:3: lint] Error 128
  make: Leaving directory '/tmp/tmp.DUUAVQCIKe/repo2/dir'
  warning: execution failed: make -C dir/ lint

What's different between what you expected and what actually happened?

See above.

[System Info]
git version:
git version 2.43.0
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
uname: Linux 6.8.0-45-generic #45-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug
30 12:02:04 UTC 2024 x86_64
compiler info: gnuc: 13.2
libc info: glibc: 2.39
$SHELL (typically, interactive shell): /usr/bin/bash


[Enabled Hooks]

^ permalink raw reply	[flat|nested] 12+ messages in thread
[parent not found: <1730787532-3757-mlmmj-5e7be4fc@vger.kernel.org>]

end of thread, other threads:[~2024-11-28 15:07 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-14 20:46 git rebase exec make -C in worktree confuses repo root dir David Moberg
2024-10-14 21:19 ` Taylor Blau
2024-10-14 21:34   ` David Moberg
2024-10-15  7:11   ` Eric Sunshine
2024-10-15 18:55     ` David Moberg
2024-10-15 20:01       ` Eric Sunshine
2024-10-16  9:15         ` Phillip Wood
2024-10-16 20:36           ` Taylor Blau
2024-10-17 21:16             ` Elijah Newren
2024-10-16 21:12           ` Eric Sunshine
2024-11-05 15:24             ` phillip.wood123
     [not found] <1730787532-3757-mlmmj-5e7be4fc@vger.kernel.org>
     [not found] ` <CAL2+Mivva3AFR4of0-2d48YDDMbHiNVsUmCzhezHfe+h9faEvQ@mail.gmail.com>
     [not found]   ` <CAPig+cTVfNW4AFJKyGbRcy0_YJEJGcNYNx57USyp4zz1g9fSeQ@mail.gmail.com>
2024-11-28 15:07     ` Phillip Wood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).