git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: fetch: tag following too ambitious?

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 28, 2013, 16:34 UTC
Message-ID
<xmqq1u35gxro.fsf@gitster.dls.corp.google.com>
In-Reply-To
<526E5BBB.6080306@alum.mit.edu>
Michael Haggerty <mhagger@alum.mit.edu> writes:
Show 38 quoted lines
> When investigating the exact semantics of tag-following, I discovered
> that the tag auto-following behavior of "git fetch" is more ambitious
> than I would have expected: it fetches any tag that references an object
> that is known to the local repository, *even if that object is not
> currently reachable* (i.e., neither reachable before the fetch or after
> the fetch of non-auto-followed references).  This makes it hard to
> renounce interest in a branch.
>
> Suppose there is a remote repo with
>
>     o---o---o        <- master
>      \
>       o---A---B      <- pu
>
> When I clone this repo, of course I get all of the commits and both
> branches.
>
> Now suppose I decide I'm not interested in "branch" anymore, so I delete
> its remote-tracking branch from my repository and change the config to
> only fetch "master":
>
>     git config remote.origin.fetch \
>             '+refs/heads/master:refs/remotes/origin/master'
>     git update-ref -d refs/remotes/origin/pu
>
> It looks like I'm free of the "pu" branch, right?
>
> But if a week later somebody pushes a tag "t" to origin that points at
> commit A, and then I do
>
>     git fetch origin
>
> then Git (un)helpfully fetches tag "t" into my repo, because even though
> commit "A" isn't reachable in my repo, it hasn't been pruned yet from
> the object database.
>
> I admit this is not likely to be a serious problem in practice, but I
> found it surprising and strangely disturbing.  I would call it a bug.

Sounds like a bug to me. Does upload-pack to pack-object codepath actually pack the tag object and give it to you, or is it done all by reconnecting an existing and dangling tag back to your ref namespace?

Previous: Michael Haggerty
Message 2 of 2 in “fetch: tag following too ambitious?”
  1. Michael HaggertyOct 28, 2013
  2. Junio C HamanoOct 28, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.