Re: [RFC/PATCH] refs: tone down the dwimmery in refname_match() for {heads,tags,remotes}/*

From: Paolo Bonzini
Date: Mon May 27 2019 - 08:36:28 EST


On 27/05/19 00:54, Ãvar ArnfjÃrà Bjarmason wrote:
> This resulted in a case[1] where someone on LKML did:
>
> git push kvm +HEAD:tags/for-linus
>
> Which would have created a new "tags/for-linus" branch in their "kvm"
> repository, except because they happened to have an existing
> "refs/tags/for-linus" reference we pushed there instead, and replaced
> an annotated tag with a lightweight tag.

Actually, I would not be surprised even if "git push foo
someref:tags/foo" _always_ created a lightweight tag (i.e. push to
refs/tags/foo).

In my opinion, the bug is that "git request-pull" should warn if the tag
is lightweight remotely but not locally, and possibly even vice versa.
Here is a simple testcase:

# setup "local" repo
mkdir -p testdir/a
cd testdir/a
git init
echo a > test
git add test
git commit -minitial

# setup "remote" repo
git clone --bare . ../b

# setup "local" tag
echo b >> test
git commit -msecond test
git tag -mtag tag1

# create remote lightweight tag and prepare a pull request
git push ../b HEAD:refs/tags/tag1
git request-pull HEAD^ ../b tags/tag1

Paolo