git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Moberg <kaddkaka@gmail.com>
To: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: git rebase exec make -C in worktree confuses repo root dir
Date: Mon, 14 Oct 2024 22:46:45 +0200	[thread overview]
Message-ID: <CAL2+Miudq0UXAb=R24v+ftZVkHy2We1CFsFAt__tCYMWtCfOow@mail.gmail.com> (raw)

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]

             reply	other threads:[~2024-10-14 20:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-14 20:46 David Moberg [this message]
2024-10-14 21:19 ` git rebase exec make -C in worktree confuses repo root dir 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAL2+Miudq0UXAb=R24v+ftZVkHy2We1CFsFAt__tCYMWtCfOow@mail.gmail.com' \
    --to=kaddkaka@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).