Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3882264ybi; Mon, 27 May 2019 07:31:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqwoOnq60P8cL3ezClFLvr8NQgZp1ZTAS6IrJyp/RgHvn6Feewd4wUmZDVEBNOiUMjIuHixs X-Received: by 2002:a17:90a:ca09:: with SMTP id x9mr31032894pjt.105.1558967462816; Mon, 27 May 2019 07:31:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558967462; cv=none; d=google.com; s=arc-20160816; b=ArGa7j5+4Wn2Ga7Ot9Gb6xAadyNlL0uNifVD1vBv0skgY0BTaIF2dvH2xDa5Jx72MA ZAgC6lGqo7qQhCPLMLcfcT5xO0Ca5ouB32wxq0ZhyyKCaPJeDYOMVacQ6vc1fuaB7t6i 8LAp6RQ+7xu3AqyXa+KD8O+g0pGqRbyePfYbxk75EYzvO3BWLS58j9ARDRu1bm1WomMP NRsJUfWZnVn3ZprS9I4cQEeNbyQk7jwxEsblWoWDrj2iz52uqWSQ+ONamHWvHHuT6OcE CQBXM1NH15QQ2pvIAoiHQxLaQKPLH7BKkWWp4s9YvOlAS6zYMbLplugDNL70b9Fd8jjv yGoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:in-reply-to:user-agent:references:subject:cc:to :from:dkim-signature; bh=R1AzxQRXU80ZX5XlNuDiv+NBZP+OSp10LmHxXSL0x0w=; b=lmliNOLkV7kbi1mZwSaYx8N+D7SLwuPubkJwdm5WIu15V8RS3ezmWnsJP3RKufRf/O xlftQzMz+YU9YDxMSGTfiPawUnA0w0brz17M488rF5b/4ndod12VLt3nce8rTsPkNjvi NjOaNa1mXku0hNG0dRz37W/DySZGSlyzdOwkdGHuYK0o5S6SjUAZOcmGUU5bB/um65gG gqiWFxoRlbOYlaPShgRloy9AGNaO0IH/EAdGoLqQD5pe0xvPrh2s8l7rh//bqgGXVvpD EQlnGwSM5BFZ2oSDBt68RdDpSuOnl8+1RxWkmuiJCRm3llwYCfVGXZ6IQpkulUSMaPjT BDBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AiCWHoCA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r69si17848440pgr.120.2019.05.27.07.30.45; Mon, 27 May 2019 07:31:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AiCWHoCA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726583AbfE0O3d (ORCPT + 99 others); Mon, 27 May 2019 10:29:33 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:39719 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726191AbfE0O3d (ORCPT ); Mon, 27 May 2019 10:29:33 -0400 Received: by mail-ed1-f65.google.com with SMTP id e24so27012775edq.6; Mon, 27 May 2019 07:29:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:user-agent:in-reply-to:date :message-id:mime-version:content-transfer-encoding; bh=R1AzxQRXU80ZX5XlNuDiv+NBZP+OSp10LmHxXSL0x0w=; b=AiCWHoCAvp7FsuBpthidNFx/02mjK0qH0iS0s0JJyqwmtUEJ7pK46F519eHsPQK9YD iHApNZRWjr9Sqaj9pfDK11l1BTfugz2Aw2qi67tjsJwz9JdfyZ21ictjTY4OtHF9lfqk UAT1fB1y84EsTHu7RIidW4w/pP025+m6r8rq4+sNHf1D8yHSDSkYLMUV1Vhm20aMmPuX j5N8KxFO/30zdUe637oW2mJrZ4on+E0uMtGuGhYUGs5gL228gRn8aTuiXdupz+8ICsa2 wIUl11FDF34EqNDQS+5QhSPlyX2Y1kdeQfsiupaIfFesi40cWWfHnGugFAbF0PAvDtZF zqjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:user-agent :in-reply-to:date:message-id:mime-version:content-transfer-encoding; bh=R1AzxQRXU80ZX5XlNuDiv+NBZP+OSp10LmHxXSL0x0w=; b=Ipxhhq3np0zp48SMXBBuQZ8DzNBvLssk7C8Kphg4/c+W5orPqgsPKGFq9QYME+wku1 +0q84AlonhsaSbnl+Jo+TKMfeLotxUu6Gnk7qlcEkwJBIpdPyJdpglO0IiIH7626uu3j nGOurZD2ebztN5OdJeJ0vfJl945ArRHmt0LPVqa3LfnmdrmItp1diTsoja+XnHVl0eV9 atelkbNMrK7IpU7Eq7TetMUt2X5QcpxqckVODlR/zmRdl6e9TxFuaa+0lyoYake0xoNp FIcdBZVghKZNeFyGx8peEP1gK9gm4vZYrzibrSAbk9Zk9otLA5x2/sNKoffFcofi9YbJ UPMw== X-Gm-Message-State: APjAAAXMFMV4Q9isB32P639sW0G26MkXOevb2M88F4FfczI+Ro6x6KLp 1KhnuL8Sv1CR/EmfBPZOtME= X-Received: by 2002:a17:906:d215:: with SMTP id w21mr53198737ejz.122.1558967371143; Mon, 27 May 2019 07:29:31 -0700 (PDT) Received: from evledraar ([5.57.21.48]) by smtp.gmail.com with ESMTPSA id v16sm3358696edm.56.2019.05.27.07.29.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 May 2019 07:29:29 -0700 (PDT) From: =?utf-8?B?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason To: Paolo Bonzini Cc: git@vger.kernel.org, Linus Torvalds , Junio C Hamano , Linux List Kernel Mailing , Radim =?utf-8?B?S3LEjW3DocWZ?= , KVM list , Michael Haggerty Subject: Re: [RFC/PATCH] refs: tone down the dwimmery in refname_match() for {heads,tags,remotes}/* References: <20190526225445.21618-1-avarab@gmail.com> <5c9ce55c-2c3a-fce0-d6e3-dfe5f8fc9b01@redhat.com> User-agent: Debian GNU/Linux 10 (buster); Emacs 26.1; mu4e 1.1.0 In-reply-to: <5c9ce55c-2c3a-fce0-d6e3-dfe5f8fc9b01@redhat.com> Date: Mon, 27 May 2019 16:29:28 +0200 Message-ID: <874l5gezsn.fsf@evledraar.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 27 2019, Paolo Bonzini wrote: > On 27/05/19 00:54, =C3=86var Arnfj=C3=B6r=C3=B0 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). That's not the intention (I think), and not what we document. It mostly (and I believe always should) works by looking at whether "someref" is a named ref, and e.g. looking at whether it's "master". We then see that it lives in "refs/heads/master" locally, and thus correspondingly add a "refs/heads/" to your "tags/foo", making it "refs/heads/tags/foo". *Or* we take e.g. :master, the is ambiguous, but we see that "master" unambiguously refers to "refs/heads/master" on the remote (so e.g. a refs/tags/master doesn't exist). If you had both refs/{heads,tags}/master refs on the remote we'd emit: error: dst refspec master matches more than one (We should improve that error to note what conflicted, #leftoverbits) So your HEAD:tags/for-linus resulted in pushing a HEAD that referred to some refs/heads/* to refs/tags/for-linus. I believe that's an unintendedem ergent effect in how we try to apply these two rules. We should apply one, not both in combination. And as an aside none of these rules have to do with whether the is a lightweight or annotated tag, and both types live in the refs/tags/* namespace. > 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 Yeah, maybe. I don't use git-request-pull. So maybe this is a simple mitigation for that tool since you supply a to it already. I was more interested and surprised by HEAD being implicitly resolved to refs/tags/* in a way that would be *different* than if you didn't have an existing tag there, but of course if we errored on that you might have just done "+HEAD:refs/tags/for-linus" and ended up with the same thing. As an aside, in *general* tags, unlike branches, don't have "remote tracking". That's something we'd eventually want, but we're nowhere near the refstore and porcelain supporting that. Thus such a check is hard to support in general, we'd always need a remote name and a network roundtrip. Otherwise we couldn't do anything sensible if you have 10 remotes of fellow LKML developers, all of whom have a "for-linus" tag, which I'm assuming is a common use-case. But since git-request-pull gets the remote it can (and does) check on that remote, but seems to satisfied to see that the ref exists somewhere on that remote.