git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rebecca Turner" <rbt@fastmail.com>
To: git@vger.kernel.org
Subject: `git worktree list` when bare repository is named `.git`
Date: Thu, 10 Oct 2024 18:12:09 -0700	[thread overview]
Message-ID: <8f961645-2b70-4d45-a9f9-72e71c07bc11@app.fastmail.com> (raw)

It seems that `.git` is always stripped from the `git worktree list` output (including in `--porcelain` mode). This becomes relevant with bare repositories. Here is a bare repository functioning as expected:

$ mkdir bare1
$ cd bare1
$ git init --bare
Initialized empty Git repository in /private/tmp/bare1/
$ git worktree list
/private/tmp/bare1  (bare)

But if we create a bare repository in a directory named `.git`, `git worktree list` displays the parent directory as the worktree, even though `git status` doesn't recognize it as a worktree:

$ mkdir -p bare2/.git
$ cd bare2/.git
$ git init --bare
Initialized empty Git repository in /private/tmp/bare2/.git/
$ git worktree list
/private/tmp/bare2  (bare)
$ cd /tmp/bare2
$ git status
fatal: this operation must be run in a work tree

However, Git _will_ recognize the parent directory (/tmp/bare2) as a Git repository for the purposes of commands like `git rev-parse --git-dir`. I suspect this can be fixed in `get_main_worktree` by only stripping a `.git` suffix from the path if the main worktree is not bare.

             reply	other threads:[~2024-10-11  1:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-11  1:12 Rebecca Turner [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-10-11  3:52 `git worktree list` when bare repository is named `.git` Caleb White
2024-10-11  4:59 ` Rebecca Turner
2024-10-11  5:36   ` Caleb White
2024-10-11 16:19     ` Rebecca Turner
2024-10-11 16:45       ` Caleb White
2024-10-11 22:17       ` Patrick Callahan
     [not found]       ` <CACt=GQry+mR7fVSUEdpPjsgSoDURk4W-DRPqLkom-f9Q0KBuTQ@mail.gmail.com>
2024-10-21 19:09         ` Rebecca Turner

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=8f961645-2b70-4d45-a9f9-72e71c07bc11@app.fastmail.com \
    --to=rbt@fastmail.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).