[BUG] worktree local refs weirdness

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux