From: Phillip Wood <phillip.wood123@gmail.com>
To: Git Mailing List <git@vger.kernel.org>
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [BUG] worktree local refs weirdness
Date: Wed, 6 Mar 2019 15:57:18 +0000 [thread overview]
Message-ID: <f6e197f2-886a-5e82-7fc4-c53737dd66cc@gmail.com> (raw)
When it is run in a worktree 'git for-each-ref' only seems to show refs
under refs/rewritten if that directory also exists under $GIT_COMMON_DIR
even though they are local to the worktree.
Initially I thought this was due to $GIT_COMMON_DIR pointing to a bare
repo, but that is not the case. However while writing a test case which
cloned to a bare repo I noticed it was listing a ref for the HEAD of a
worktree in the repo I had cloned from, not the clone itself.
The script below reproduces both issues, I've copied the output below
it. I'm not sure what's going on or the best way to debug it.
Best Wishes
Phillip
# setup initial repo
mkdir repo &&
cd repo &&
git init &&
echo a>a &&
git add a &&
git commit -ma &&
#add a worktree and set a ref under refs/rewritten
git worktree add ../worktree-1 &&
cd ../worktree-1 &&
echo 'worktree-1 adding refs/rewritten/a' &&
git update-ref refs/rewritten/a HEAD &&
git rev-parse --verify refs/rewritten/a &&
echo 'refs/rewritten/a exists but is not shown' &&
git for-each-ref &&
# add a ref under refs/rewritten to the main repo
cd ../repo &&
echo 'repo adding refs/rewritten/z' &&
git update-ref refs/rewritten/z HEAD &&
git for-each-ref &&
cd ../worktree-1 &&
echo 'worktree-1 now shows refs/rewritten/a' &&
git for-each-ref &&
cd .. &&
# create a bare clone with a worktree
git clone --bare --no-local repo bare &&
cd bare &&
git worktree add ../worktree-2 &&
cd ../worktree-2 &&
echo 'worktree-2 adding refs/rewritten/b' &&
echo 'why does this show refs/worktree-1/head' &&
echo 'but not refs/rewritten/b?' &&
git worktree list &&
git update-ref refs/rewritten/b HEAD &&
git rev-parse --verify refs/rewritten/b &&
git for-each-ref
Output
Initialized empty Git repository in
/home/phil/src/git-utils/dev/git-rewrite/repo/.git/
[master (root-commit) dc2045a] a
1 file changed, 1 insertion(+)
create mode 100644 a
Preparing worktree (new branch 'worktree-1')
HEAD is now at dc2045a a
worktree-1 adding refs/rewritten/a
dc2045a36f38ba4e9bacd8cd86ba74f58a1d4656
refs/rewritten/a exists but is not shown
dc2045a36f38ba4e9bacd8cd86ba74f58a1d4656 commit refs/heads/master
dc2045a36f38ba4e9bacd8cd86ba74f58a1d4656 commit refs/heads/worktree-1
repo adding refs/rewritten/z
dc2045a36f38ba4e9bacd8cd86ba74f58a1d4656 commit refs/heads/master
dc2045a36f38ba4e9bacd8cd86ba74f58a1d4656 commit refs/heads/worktree-1
dc2045a36f38ba4e9bacd8cd86ba74f58a1d4656 commit refs/rewritten/z
worktree-1 now shows refs/rewritten/a
dc2045a36f38ba4e9bacd8cd86ba74f58a1d4656 commit refs/heads/master
dc2045a36f38ba4e9bacd8cd86ba74f58a1d4656 commit refs/heads/worktree-1
dc2045a36f38ba4e9bacd8cd86ba74f58a1d4656 commit refs/rewritten/a
Cloning into bare repository 'bare'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.
Preparing worktree (new branch 'worktree-2')
HEAD is now at dc2045a a
worktree-2 adding refs/rewritten/b
why does this show refs/worktree-1/head
but not refs/rewritten/b?
/home/phil/src/git-utils/dev/git-rewrite/bare (bare)
/home/phil/src/git-utils/dev/git-rewrite/worktree-2 dc2045a [worktree-2]
dc2045a36f38ba4e9bacd8cd86ba74f58a1d4656
dc2045a36f38ba4e9bacd8cd86ba74f58a1d4656 commit refs/heads/master
dc2045a36f38ba4e9bacd8cd86ba74f58a1d4656 commit refs/heads/worktree-1
dc2045a36f38ba4e9bacd8cd86ba74f58a1d4656 commit refs/heads/worktree-2
next reply other threads:[~2019-03-06 15:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-06 15:57 Phillip Wood [this message]
2019-03-07 9:38 ` [BUG] worktree local refs weirdness Phillip Wood
2019-03-07 9:46 ` Duy Nguyen
2019-03-07 10:20 ` Duy Nguyen
2019-03-07 12:29 ` [PATCH 0/3] Fix refs/rewritten not show up in for-each-ref Nguyễn Thái Ngọc Duy
2019-03-07 12:29 ` [PATCH 1/3] files-backend.c: factor out per-worktree code in loose_fill_ref_dir() Nguyễn Thái Ngọc Duy
2019-03-07 12:29 ` [PATCH 2/3] files-backend.c: reduce duplication in add_per_worktree_entries_to_dir() Nguyễn Thái Ngọc Duy
2019-03-07 14:44 ` Phillip Wood
2019-03-07 12:29 ` [PATCH 3/3] Make sure refs/rewritten/ is per-worktree Nguyễn Thái Ngọc Duy
2019-03-07 14:45 ` Phillip Wood
2019-03-07 14:51 ` Duy Nguyen
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=f6e197f2-886a-5e82-7fc4-c53737dd66cc@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
--cc=phillip.wood@dunelm.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.