{"thread":{"id":"51957","subject":"missing tags from \"git fetch\"","startedAt":"2019-10-02T13:18:48Z","lastAt":"2019-11-22T13:00:23Z","messageCount":5,"participants":["Martin Nicolay","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"383272","messageId":"alpine.LSU.2.20.1910021431130.32588@cpza.bfz-tzou.qr","threadId":"51957","inReplyTo":null,"subject":"missing tags from \"git fetch\"","fromName":"Martin Nicolay","fromEmail":"m.nicolay@osm-ag.de","sentAt":"2019-10-02T13:10:12Z","receivedAt":"2019-10-02T13:18:48Z","isPatch":false,"sender":{"key":"m.nicolay@osm-ag.de","avatar":null},"body":"Hi!\n\nI don't know if this is a lack of understanding or a software or \ndocumentation bug.\n\nman git-fetch says about tags:\n        By default, any tag that points into the histories being fetched is\n        also fetched; the effect is to fetch tags that point at branches that\n        you are interested in.\n\nIf I fetch without --tags the tags that point to the commits of the \nfetched branch are not fetched. If I fetch with --tags than all tags are \nfetched but I only wish to fetch tags pointing to something in the \nbranch fetched.\n\nHere is a self contained example:\n--------------------------\n$ cd /tmp\n$ git init r1 && cd r1\nInitialized empty Git repository in /tmp/r1/.git/\n$ date >f1\n$ git add f1\n$ git commit -minitial f1\n[master (root-commit) 61753c60ac] initial\n  1 file changed, 1 insertion(+)\n  create mode 100644 f1\n$ git tag -mt1 t1\n$ git tag t2\n$ git init ../r2 && cd ../r2\nInitialized empty Git repository in /tmp/r2/.git/\n$ git remote add origin $(cd ../r1; pwd)\n$ git fetch origin master\nremote: Enumerating objects: 3, done.\nremote: Counting objects: 100% (3/3), done.\nremote: Total 3 (delta 0), reused 0 (delta 0)\nUnpacking objects: 100% (3/3), done.\nFrom /tmp/r1\n  * branch                  master     -> FETCH_HEAD\n  * [new branch]            master     -> origin/master\n$ git tag | wc\n       0       0       0\n$ git fetch --tags origin master\nremote: Enumerating objects: 1, done.\nremote: Counting objects: 100% (1/1), done.\nremote: Total 1 (delta 0), reused 0 (delta 0)\nUnpacking objects: 100% (1/1), done.\nFrom /tmp/r1\n  * branch                  master     -> FETCH_HEAD\n  * [new tag]               t1         -> t1\n  * [new tag]               t2         -> t2\n$ git tag | wc\n       2       2       6\n$ git rev-parse FETCH_HEAD\n61753c60ac550a5315b7c930a701b94f36e08e4f\n$ git rev-parse t1^{commit}\n61753c60ac550a5315b7c930a701b94f36e08e4f\n$ git rev-parse t2^{commit}\n61753c60ac550a5315b7c930a701b94f36e08e4f\n--------------------------\n\nObviously the two tags point to the fetched commit but without --tags \nthey are not fetched. The behavior is identical for lightweight and \nannotated tags.\n\nBest regards\nMartin Nicolay\n\n-- \n\nNo MS-Word attachments (http://www.gnu.org/philosophy/no-word-attachments.html)\n_______________________________________________________________________________\nOSM AG | Ruhrallee 191 | 45136 Essen | Fon: 0201-89 555 | Fax: 0201-89 55 400\nweb: www.osm-ag.de | e-mail: info@osm-ag.de\nIBAN: DE67 4325 0030 0001 0059 82 | BIC: WELADED1HRN\nUSt-ldNr.: DE163337313 | HRB: 28171 Essen\nAufsichtsratsvorsitzende: Dipl.-Kff. Sabine Elsas\nVorstand: Johannes Kuhn (Vorsitzender), Christian Damsky, Axel Roland\n\n--\nDiese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen.\nWenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten\nhaben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail.\nDas unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht\ngestattet.\n_______________________________________________________________________________"},{"id":"383274","messageId":"20191002135518.GA3599@sigill.intra.peff.net","threadId":"51957","inReplyTo":"alpine.LSU.2.20.1910021431130.32588@cpza.bfz-tzou.qr","subject":"Re: missing tags from \"git fetch\"","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-10-02T13:55:19Z","receivedAt":"2019-10-02T13:55:21Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Oct 02, 2019 at 03:10:12PM +0200, Martin Nicolay wrote:\n\n> I don't know if this is a lack of understanding or a software or\n> documentation bug.\n> \n> man git-fetch says about tags:\n>        By default, any tag that points into the histories being fetched is\n>        also fetched; the effect is to fetch tags that point at branches that\n>        you are interested in.\n> \n> If I fetch without --tags the tags that point to the commits of the fetched\n> branch are not fetched. If I fetch with --tags than all tags are fetched but\n> I only wish to fetch tags pointing to something in the branch fetched.\n\nIt's a documentation bug, I think. We won't auto-follow tags when\nfetching into FETCH_HEAD (but this is further confused by the fact that\nfetching into FETCH_HEAD will auto-update a tracking ref).\n\nSo instead of this:\n\n> $ git fetch origin master\n\ntry this:\n\n  $ git fetch origin\n\nor even this:\n\n  $ git fetch origin master:refs/remotes/origin/master\n\nThere's more discussion in this thread (but it looks like no patches\never came out of it):\n\n  https://public-inbox.org/git/20170817092853.hteuzni5lxia4ejf@sigill.intra.peff.net/\n\n-Peff\n"},{"id":"383276","messageId":"alpine.LSU.2.20.1910021707570.32588@cpza.bfz-tzou.qr","threadId":"51957","inReplyTo":"20191002135518.GA3599@sigill.intra.peff.net","subject":"Re: missing tags from \"git fetch\"","fromName":"Martin Nicolay","fromEmail":"m.nicolay@osm-ag.de","sentAt":"2019-10-02T15:24:22Z","receivedAt":"2019-10-02T15:24:29Z","isPatch":false,"sender":{"key":"m.nicolay@osm-ag.de","avatar":null},"body":"On Wednesday 2019-10-02 15:55, Jeff King wrote:\n> So instead of this:\n>\n>> $ git fetch origin master\n>\n> try this:\n>\n>  $ git fetch origin\n\nIt creates the master branch. This is what I'm trying to avoid.\n\n> or even this:\n>\n>  $ git fetch origin master:refs/remotes/origin/master\n\nBingo. It's ugly but it works. Problem solved :-).\n\n> There's more discussion in this thread (but it looks like no patches\n> ever came out of it):\n>\n>  https://public-inbox.org/git/20170817092853.hteuzni5lxia4ejf@sigill.intra.peff.net/\n\nThe explanation makes a kind of sense, but if someone want to avoid \npolluting the tags when fetching into FETCH_HEAD one could get it with \n--no-tags. So this is more of a misguided attempt to get a seemingly \nsensible default while destroying a consistent behaviour.\n\nSometimes I can see why people say git is confusing ;-).\n\nThanks\nMartin Nicolay\n\n-- \n\nNo MS-Word attachments (http://www.gnu.org/philosophy/no-word-attachments.html)\n_______________________________________________________________________________\nOSM AG | Ruhrallee 191 | 45136 Essen | Fon: 0201-89 555 | Fax: 0201-89 55 400\nweb: www.osm-ag.de | e-mail: info@osm-ag.de\nIBAN: DE67 4325 0030 0001 0059 82 | BIC: WELADED1HRN\nUSt-ldNr.: DE163337313 | HRB: 28171 Essen\nAufsichtsratsvorsitzende: Dipl.-Kff. Sabine Elsas\nVorstand: Johannes Kuhn (Vorsitzender), Christian Damsky, Axel Roland\n\n--\nDiese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen.\nWenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten\nhaben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail.\nDas unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht\ngestattet.\n_______________________________________________________________________________"},{"id":"384852","messageId":"alpine.LSU.2.20.1910251150411.2754@cpza.bfz-tzou.qr","threadId":"51957","inReplyTo":"20191002135518.GA3599@sigill.intra.peff.net","subject":"Re: missing tags from \"git fetch\"","fromName":"Martin Nicolay","fromEmail":"m.nicolay@osm-ag.de","sentAt":"2019-10-25T10:17:26Z","receivedAt":"2019-10-25T10:17:32Z","isPatch":false,"sender":{"key":"m.nicolay@osm-ag.de","avatar":null},"body":"Hi!\n\nOn Wednesday 2019-10-02 15:55, Jeff King wrote:\n> It's a documentation bug, I think. We won't auto-follow tags when\n> fetching into FETCH_HEAD (but this is further confused by the fact that\n> fetching into FETCH_HEAD will auto-update a tracking ref).\n>\n> So instead of this:\n>\n>> $ git fetch origin master\n>\n> try this:\n>\n>  $ git fetch origin\n>\n> or even this:\n>\n>  $ git fetch origin master:refs/remotes/origin/master\n\nI thought it would work, but it works only once. On the second time the \nref for the remote branch is deleted. It seems git is confused by \nspecifying a ref it expect to manage itself.\n\nIs there any other way to force auto-follow tags? If there is no sane \nway, I have to create a throwawy branch and delete it immediately.\n\n=====================================================\n$ git fetch origin master:refs/remotes/origin/master\nremote: Enumerating objects: 4, done.\nremote: Counting objects: 100% (4/4), done.\nremote: Compressing objects: 100% (2/2), done.\nremote: Total 4 (delta 0), reused 0 (delta 0)\nUnpacking objects: 100% (4/4), done.\nFrom /tmp/r1\n  * [new branch]            master     -> origin/master\n  * [new tag]               t1         -> t1\n  * [new tag]               t2         -> t2\n$ ls .git/refs/remotes/origin\nmaster\n$ git fetch origin master:refs/remotes/origin/master\nFrom /tmp/r1\n  - [deleted]               (none)     -> origin/master\n$ ls .git/refs/remotes/origin\n/bin/ls: cannot access .git/refs/remotes/origin: No such file or directory\n$ git fetch origin master:refs/remotes/origin/master\nFrom /tmp/r1\n  * [new branch]            master     -> origin/master\n$ ls .git/refs/remotes/origin\nmaster\n$ git --version\ngit version 2.23.0\n=====================================================\n\nBest regards\nMartin Nicolay\n\n-- \n_______________________________________________________________________________\nNo MS-Word attachments (http://www.gnu.org/philosophy/no-word-attachments.html)\n_______________________________________________________________________________\nOSM AG | Ruhrallee 191 | 45136 Essen | Fon: 0201-89 555 | Fax: 0201-89 55 400\nweb: www.osm-ag.de | e-mail: info@osm-ag.de\nIBAN: DE67 4325 0030 0001 0059 82 | BIC: WELADED1HRN\nUSt-ldNr.: DE163337313 | HRB: 28171 Essen\nAufsichtsratsvorsitzende: Dipl.-Kff. Sabine Elsas\nVorstand: Johannes Kuhn (Vorsitzender), Christian Damsky, Axel Roland\n\n--\nDiese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen.\nWenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten\nhaben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail.\nDas unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht\ngestattet.\n_______________________________________________________________________________"},{"id":"386819","messageId":"20191122130020.GA22423@sigill.intra.peff.net","threadId":"51957","inReplyTo":"alpine.LSU.2.20.1910251150411.2754@cpza.bfz-tzou.qr","subject":"Re: missing tags from \"git fetch\"","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-11-22T13:00:20Z","receivedAt":"2019-11-22T13:00:23Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Oct 25, 2019 at 12:17:26PM +0200, Martin Nicolay wrote:\n\n> >  $ git fetch origin master:refs/remotes/origin/master\n> \n> I thought it would work, but it works only once. On the second time the ref\n> for the remote branch is deleted. It seems git is confused by specifying a\n> ref it expect to manage itself.\n\nIt seems like a bad interaction with `fetch.prune` (I don't have it set,\nand the problem doesn't appear, but if I set it, I can reproduce your\nissue).\n\nI'm not sure why, though. It's true that the ref _is_ mentioned in the\nconfigured refspec for origin, but we shouldn't be looking at that\nrefspec at all (since we have a refspec on the command line).\n\n-Peff\n"}]}