mirror of
https://github.com/git/git.git
synced 2024-11-15 05:33:04 +01:00
f8fb971eac
In a repository cloned from somewhere else, you typically have a
symbolic ref refs/remotes/origin/HEAD pointing at the 'master'
remote-tracking ref that is next to it. When fetching into such a
repository with "git fetch --mirror" from another repository that
was similarly cloned, the implied wildcard refspec refs/*:refs/*
will end up asking to update refs/remotes/origin/HEAD with the
object at refs/remotes/origin/HEAD at the remote side, while asking
to update refs/remotes/origin/master the same way. Depending on the
order the two updates happen, the latter one would find that the
value of the ref before it is updated has changed from what the code
expects.
When the user asks to update the underlying ref via the symbolic ref
explicitly without using a wildcard refspec, e.g. "git fetch $there
refs/heads/master:refs/remotes/origin/HEAD", we should still let him
do so, but when expanding wildcard refs, it will result in a more
intuitive outcome if we simply ignore local symbolic refs.
As the purpose of the symbolic ref refs/remotes/origin/HEAD is to
follow the ref it points at (e.g. refs/remotes/origin/master), its
value would change when the underlying ref is updated.
Earlier commit da3efdb
(receive-pack: detect aliased updates which
can occur with symrefs, 2010-04-19) fixed a similar issue for "git
push".
Signed-off-by: Junio C Hamano <gitster@pobox.com>
42 lines
1 KiB
Bash
Executable file
42 lines
1 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='avoiding conflicting update thru symref aliasing'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'setup' '
|
|
test_commit one &&
|
|
git clone . src &&
|
|
git clone src dst1 &&
|
|
git clone src dst2 &&
|
|
test_commit two &&
|
|
( cd src && git pull )
|
|
'
|
|
|
|
test_expect_success 'push' '
|
|
(
|
|
cd src &&
|
|
git push ../dst1 "refs/remotes/*:refs/remotes/*"
|
|
) &&
|
|
git ls-remote src "refs/remotes/*" >expect &&
|
|
git ls-remote dst1 "refs/remotes/*" >actual &&
|
|
test_cmp expect actual &&
|
|
( cd src && git symbolic-ref refs/remotes/origin/HEAD ) >expect &&
|
|
( cd dst1 && git symbolic-ref refs/remotes/origin/HEAD ) >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_expect_success 'fetch' '
|
|
(
|
|
cd dst2 &&
|
|
git fetch ../src "refs/remotes/*:refs/remotes/*"
|
|
) &&
|
|
git ls-remote src "refs/remotes/*" >expect &&
|
|
git ls-remote dst2 "refs/remotes/*" >actual &&
|
|
test_cmp expect actual &&
|
|
( cd src && git symbolic-ref refs/remotes/origin/HEAD ) >expect &&
|
|
( cd dst2 && git symbolic-ref refs/remotes/origin/HEAD ) >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_done
|