Subject: Re: Proposal for pruning tags

From: Junio C Hamano <[email-masked]>
Date: Thu, 05 Jun 2014 13:50:58 -0700

Robert Dailey <[email-masked]> writes:

> I've never contributed to the Git project before. I'm a Windows user,
> so I use msysgit, but I'd be happy to install linux just so I can help
> implement this feature if everyone feels it would be useful.
>
> Right now AFAIK, there is no way to prune tags through Git. The way I
> currently do it is like so:
>
> $ git tag -l | xargs git tag -d
> $ git fetch --all

I think you need to explain what you mean by "prune" a lot better
than what you are doing in your message to be understood by others.

After seeing the above two commands, my *guess* of what you want to
do is to remove any of your local tag that is *not* present in the
repository you usually fetch from (aka "origin"), but that directly
contradicts with what you said you wish, i.e.

> This is not only wasteful, but dangerous. I might accidentally delete
> a local tag I haven't pushed yet...

which only shows that your definition of "prune" is different from
"remove what I do not have at 'origin'".

But it does not say *how* that is different.  How should "prune"
behave differently from the two commands above?  How does your
"prune" decide a tag needs to be removed locally when it is not at
your "origin" [*1*]?

There is *nothing* in git that lets you look at a local tag that is
missing from the other side and determine if that is something you
did not want to push (hence it is missing there) of if that is
something you forgot to push (hence it is missing there but you
would rather have pushed if you did not forget).  So you must have
some new mechanism to record and/or infer that distinction in mind,
but it is not clear what it is from your message.

So until that is clarified, there is not much more to say if your
"feature" has any merit---as there is no way to tell what that
"feature" exactly is, at least not yet ;-)

[Footnote]

*1* By the way, removing and then refetching would be a silly way to
    do this kind of thing anyway.  After removing but before you
    have a chance to fetch, your ISP may severe your network
    connection and then what happens?

    Whatever your definition of "prune" is, I would think it would
    be built around "ls-remote --tags" output, to see what tags the
    other repository (or other repositories, by looping over the
    remotes you interact with) have, compare that set with the tags
    you locally have in order to decide which subset of tags you
    locally have to remove.