{"thread":{"id":"36847","subject":"Proposal for pruning tags","startedAt":"2014-06-05T14:51:47Z","lastAt":"2014-06-11T09:25:56Z","messageCount":5,"participants":["Robert Dailey","Junio C Hamano","Michael Haggerty"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"243398","messageId":"CAHd499BLX3q2FHLfFpq_14w2mmosywfRqMHVjkke0BRhAAjx7g@mail.gmail.com","threadId":"36847","inReplyTo":null,"subject":"Proposal for pruning tags","fromName":"Robert Dailey","fromEmail":"rcdailey.lists@gmail.com","sentAt":"2014-06-05T14:51:47Z","receivedAt":"2014-06-05T14:51:47Z","isPatch":false,"sender":{"key":"rcdailey.lists@gmail.com","avatar":null},"body":"I've never contributed to the Git project before. I'm a Windows user,\nso I use msysgit, but I'd be happy to install linux just so I can help\nimplement this feature if everyone feels it would be useful.\n\nRight now AFAIK, there is no way to prune tags through Git. The way I\ncurrently do it is like so:\n\n$ git tag -l | xargs git tag -d\n$ git fetch --all\n\nThis is not only wasteful, but dangerous. I might accidentally delete\na local tag I haven't pushed yet. What would be great is if we had the\nfollowing:\n\ngit tag prune [<remote>|--all]\n\nThe <remote> is needed in decentralized workflows (upstream vs\norigin). I'd also like to see an `--all` option in place of the\nremote, which means it will prune local tags from all remotes. I'm not\nsure if this command line structure will work, but it can be altered\nas necessary.\n\nAlternatively, this might also make sense on the remote command:\n\ngit remote prune <remote> --tags\n\nAgain I'm not an expert at the internals of Git, so I wanted to share\nmy idea with the community first to see if this holds water or if\nthere is already some built in way of doing this. Thanks for hearing\nout my idea!\n"},{"id":"243418","messageId":"xmqqoay7rsgd.fsf@gitster.dls.corp.google.com","threadId":"36847","inReplyTo":"CAHd499BLX3q2FHLfFpq_14w2mmosywfRqMHVjkke0BRhAAjx7g@mail.gmail.com","subject":"Re: Proposal for pruning tags","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-06-05T20:50:58Z","receivedAt":"2014-06-05T20:50:58Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Robert Dailey <rcdailey.lists@gmail.com> writes:\n\n> I've never contributed to the Git project before. I'm a Windows user,\n> so I use msysgit, but I'd be happy to install linux just so I can help\n> implement this feature if everyone feels it would be useful.\n>\n> Right now AFAIK, there is no way to prune tags through Git. The way I\n> currently do it is like so:\n>\n> $ git tag -l | xargs git tag -d\n> $ git fetch --all\n\nI think you need to explain what you mean by \"prune\" a lot better\nthan what you are doing in your message to be understood by others.\n\nAfter seeing the above two commands, my *guess* of what you want to\ndo is to remove any of your local tag that is *not* present in the\nrepository you usually fetch from (aka \"origin\"), but that directly\ncontradicts with what you said you wish, i.e.\n\n> This is not only wasteful, but dangerous. I might accidentally delete\n> a local tag I haven't pushed yet...\n\nwhich only shows that your definition of \"prune\" is different from\n\"remove what I do not have at 'origin'\".\n\nBut it does not say *how* that is different.  How should \"prune\"\nbehave differently from the two commands above?  How does your\n\"prune\" decide a tag needs to be removed locally when it is not at\nyour \"origin\" [*1*]?\n\nThere is *nothing* in git that lets you look at a local tag that is\nmissing from the other side and determine if that is something you\ndid not want to push (hence it is missing there) of if that is\nsomething you forgot to push (hence it is missing there but you\nwould rather have pushed if you did not forget).  So you must have\nsome new mechanism to record and/or infer that distinction in mind,\nbut it is not clear what it is from your message.\n\nSo until that is clarified, there is not much more to say if your\n\"feature\" has any merit---as there is no way to tell what that\n\"feature\" exactly is, at least not yet ;-)\n\n\n[Footnote]\n\n*1* By the way, removing and then refetching would be a silly way to\n    do this kind of thing anyway.  After removing but before you\n    have a chance to fetch, your ISP may severe your network\n    connection and then what happens?\n\n    Whatever your definition of \"prune\" is, I would think it would\n    be built around \"ls-remote --tags\" output, to see what tags the\n    other repository (or other repositories, by looping over the\n    remotes you interact with) have, compare that set with the tags\n    you locally have in order to decide which subset of tags you\n    locally have to remove.\n"},{"id":"243469","messageId":"CAHd499A2c09am7iFU9st-9MiNqBh_2SSyMqm+54cKL+Yq27fWA@mail.gmail.com","threadId":"36847","inReplyTo":"xmqqoay7rsgd.fsf@gitster.dls.corp.google.com","subject":"Re: Proposal for pruning tags","fromName":"Robert Dailey","fromEmail":"rcdailey.lists@gmail.com","sentAt":"2014-06-06T13:54:30Z","receivedAt":"2014-06-06T13:54:30Z","isPatch":false,"sender":{"key":"rcdailey.lists@gmail.com","avatar":null},"body":"On Thu, Jun 5, 2014 at 3:50 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> I think you need to explain what you mean by \"prune\" a lot better\n> than what you are doing in your message to be understood by others.\n>\n> After seeing the above two commands, my *guess* of what you want to\n> do is to remove any of your local tag that is *not* present in the\n> repository you usually fetch from (aka \"origin\"), but that directly\n> contradicts with what you said you wish, i.e.\n>\n>> This is not only wasteful, but dangerous. I might accidentally delete\n>> a local tag I haven't pushed yet...\n>\n> which only shows that your definition of \"prune\" is different from\n> \"remove what I do not have at 'origin'\".\n>\n> But it does not say *how* that is different.  How should \"prune\"\n> behave differently from the two commands above?  How does your\n> \"prune\" decide a tag needs to be removed locally when it is not at\n> your \"origin\" [*1*]?\n>\n> There is *nothing* in git that lets you look at a local tag that is\n> missing from the other side and determine if that is something you\n> did not want to push (hence it is missing there) of if that is\n> something you forgot to push (hence it is missing there but you\n> would rather have pushed if you did not forget).  So you must have\n> some new mechanism to record and/or infer that distinction in mind,\n> but it is not clear what it is from your message.\n>\n> So until that is clarified, there is not much more to say if your\n> \"feature\" has any merit---as there is no way to tell what that\n> \"feature\" exactly is, at least not yet ;-)\n> <snip>\n\nYou're right I didn't clarify, although I feel you're not providing\nthe most welcome response to someone who isn't as familiar with the\ninternals of Git as you are.\n\nIt was an oversight on my part. What I was expecting is that it would\nbehave exactly like branch pruning does, but that would require\n\"remote tracking tags\", which we don't have. So, apparently my idea\ndoesn't hold much water.\n\nThe general problem I see in the day to day workflow with my team is\nthat if tags exist locally and they push, those tags continuously get\nrecreated on the remote repo even after I delete them remotely. So I\ncan never truly delete tags until I go to each person and make sure\nthe tool they're using isn't accidentally pushing tags. For example,\nSourceTree pushes all tags by default. Everyone on my team is new to\nGit, so they don't know to turn that off. Having git clean up tags\nautomatically would really help with this, even though you may not\nfeel it's the responsibility of Git. It's more of a usability issue,\nit's just prone to error.\n\nI can setup my config to prune tracking branches after I pull. Having\nsomething like this for tags would be wonderful. However, this\nrequires a bigger overhaul than what I initially was proposing.\n"},{"id":"243504","messageId":"xmqqa99qq7m7.fsf@gitster.dls.corp.google.com","threadId":"36847","inReplyTo":"CAHd499A2c09am7iFU9st-9MiNqBh_2SSyMqm+54cKL+Yq27fWA@mail.gmail.com","subject":"Re: Proposal for pruning tags","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-06-06T17:18:40Z","receivedAt":"2014-06-06T17:18:40Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Robert Dailey <rcdailey.lists@gmail.com> writes:\n\n> ... Having git clean up tags\n> automatically would really help with this, even though you may not\n> feel it's the responsibility of Git. It's more of a usability issue,\n\nI agree with \"Having ... help with this\".  I did not say at all that\nit is not something Git should and can try to help.  I also agree\nwith it is a usability issue.\n\nThe thing is, the word \"automatically\" in your \"clean up tags\nautomatically\" is still too loose a definition of what we want, and\nwe cannot come up with a way to help users without tightening that\nlooseness.  As you said, you are looking for something that can tell\nbetween two kinds of tags that locally exist without having a copy\nat the 'origin':\n\n - ones that you do not want to keep\n - others that you haven't pushed to (or forgot to push to) 'origin'\n\nwithout giving the users a way to help Git to tell these two kinds\napart and only remove the former.\n\nSo...\n"},{"id":"243888","messageId":"539820A4.6090708@alum.mit.edu","threadId":"36847","inReplyTo":"CAHd499BLX3q2FHLfFpq_14w2mmosywfRqMHVjkke0BRhAAjx7g@mail.gmail.com","subject":"Re: Proposal for pruning tags","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2014-06-11T09:25:56Z","receivedAt":"2014-06-11T09:25:56Z","isPatch":false,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 06/05/2014 04:51 PM, Robert Dailey wrote:\n> I've never contributed to the Git project before. I'm a Windows user,\n> so I use msysgit, but I'd be happy to install linux just so I can help\n> implement this feature if everyone feels it would be useful.\n> \n> Right now AFAIK, there is no way to prune tags through Git. The way I\n> currently do it is like so:\n> \n> $ git tag -l | xargs git tag -d\n> $ git fetch --all\n\nJunio explained some limitations of tags (namely that there is only one\ntags namespace that is shared project-wide) that makes your wish\nimpossible to implement the way it works for branches.\n\nLocal tags are awkward for the same reason.  It is too easy to push them\naccidentally to a central repository and too hard to delete them after\nthat has happened.  They kindof spread virally, as you have noticed.  I\nrecommend against using local tags in general.\n\nRecent Git does have a feature that might help you.  *If* you have a\ncentral repository that is \"authoritative\" WRT tags, then you can sync\nthe tags in your local repository to the tags in the central repo using\n\n    git fetch --prune $REMOTE +refs/tags/*:refs/tags/*\n\nYou might also be able to use a pre-receive hook on the central repo to\nprevent tags from being pushed by people who shouldn't be doing so, or\nto require that tags have an approved format (like\nrefs/tags/release-\\d+\\.\\d+\\.\\d+ or whatever) to try to prevent a\nrecurrence of the problem.\n\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"}]}