git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russell Stuart <russell+git.vger.kernel.org@stuart.id.au>
To: git@vger.kernel.org
Subject: "git worktree repair" modifies the wrong repository
Date: Thu, 19 Sep 2024 11:12:03 +1000	[thread overview]
Message-ID: <E1sr5iF-0007zV-2k@binarylane-bailey.stuart.id.au> (raw)

What did you do before the bug happened? (Steps to reproduce your issue)
    /tmp$ mkdir -p gb/a gb/b
    /tmp$ cd gb/a
    /tmp/gb/a$ git init r
    Initialized empty Git repository in /tmp/gb/a/r/.git/
    /tmp/gb/a$ cd r
    /tmp/gb/a/r$ touch x
    /tmp/gb/a/r$ git add x
    /tmp/gb/a/r$ git commit -am .
    [main (root-commit) 6323b04] .
    1 file changed, 0 insertions(+), 0 deletions(-)
    create mode 100644 x
    /tmp/gb/a/r$ git branch foo
    /tmp/gb/a/r$ git worktree add ../r.foo
    Preparing worktree (new branch 'r.foo')
    HEAD is now at 6323b04 .
    /tmp/gb/a/r$ -r cp ../* ../../b/.
    -bash: -r: command not found
    /tmp/gb/a/r$ cp -a ../* ../../b/.
    /tmp/gb/a/r$ cd ../../b/r
    /tmp/gb/b/r$ git worktree repair ../r.foo
    repair: gitdir incorrect: /tmp/gb/a/r/.git/worktrees/r.foo/gitdir
    repair: .git file incorrect: /tmp/gb/a/r.foo
    /tmp/gb/b/r$ cat .git/worktrees/r.foo/gitdir 
    /tmp/gb/a/r.foo/.git
    /tmp/gb/b/r$ cat ../r.foo/.git
    gitdir: /tmp/gb/a/r/.git/worktrees/r.foo
    /tmp/gb/b/r$ cat ../../a/.git/worktrees/r.foo/gitdir 
    cat: ../../a/.git/worktrees/r.foo/gitdir: No such file or directory
    /tmp/gb/b/r$ cat ../../a/r/.git/worktrees/r.foo/gitdir 
    /tmp/gb/b/r.foo/.git
    /tmp/gb/b/r$ cat ../../a/r.foo/.git
    gitdir: /tmp/gb/b/r/.git/worktrees/r.foo
    /tmp/gb/b/r$ 

What did you expect to happen? (Expected behavior)
    I expected "/tmp/gb/b/r$ git worktree repair ../r.foo" to alter the
    repositories it was run from, ie those under the directory "/tmp/gb/b".

What happened instead? (Actual behavior)
    "/tmp/gb/b/r$ git worktree repair ../r.foo" modified the repositories
    under the directory "/tmp/gb/a".

[System Info]
git version:
git version 2.39.3 (Apple Git-146)
cpu: arm64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
uname: Darwin 23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:21 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T8103 arm64
compiler info: clang: 15.0.0 (clang-1500.3.9.4)
libc info: no libc information available
$SHELL (typically, interactive shell): /opt/homebrew/bin/bash


--
Regards,
Russell Stuart

             reply	other threads:[~2024-09-19  1:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-19  1:12 Russell Stuart [this message]
2024-09-19  8:58 ` "git worktree repair" modifies the wrong repository Eric Sunshine
2024-09-19 10:16   ` Russell Stuart
2024-09-19 10:47     ` Eric Sunshine
2024-09-19 11:40       ` Russell Stuart
2024-09-23 18:52         ` Eric Sunshine
2024-09-24 13:53           ` Phillip Wood
2024-10-03  6:28             ` Eric Sunshine
2024-10-04  9:15               ` phillip.wood123
2024-10-04 15:50                 ` Junio C Hamano
2024-09-25  9:31           ` Russell Stuart

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=E1sr5iF-0007zV-2k@binarylane-bailey.stuart.id.au \
    --to=russell+git.vger.kernel.org@stuart.id.au \
    --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).