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

Re: [BUG?] Fetching a single tag to a local tag requires `--no-tags`

From
Philippe Blain <levraiphilippeblain@gmail.com>
Date
Jul 15, 2020, 13:05 UTC
Message-ID
<7FB8592A-61FA-450C-B689-9E2DF879A292@gmail.com>
In-Reply-To
<20200715072726.GA3249056@coredump.intra.peff.net>
Hi Peff,
Show 26 quoted lines
> Le 15 juil. 2020 à 03:27, Jeff King <peff@peff.net> a écrit :
> 
> On Tue, Jul 14, 2020 at 10:17:59PM -0400, Philippe Blain wrote:
> 
>> If I want to fetch a single tag from a remote repository to a local tag,
>> it seems I have to use `--no-tags`, or else all tags on the remote are fetched:
>> 
>> git remote add ggg https://github.com/gitgitgadget/git
>> # this command fetches all tags on Gitgitgadget
>> git fetch ggg tag pr-590/phil-blain/doc-log-multiple-ranges-v2
>> # this command fetches only the tag listed on the command line
>> git fetch ggg tag pr-590/phil-blain/doc-log-multiple-ranges-v2 --no-tags
> 
> Hmm, that's not what I see:
> 
>  $ git clone -q https://github.com/git/git tmp
>  $ cd tmp
>  $ git remote add ggg https://github.com/gitgitgadget/git
>  $ git fetch ggg tag pr-590/phil-blain/doc-log-multiple-ranges-v2
>  remote: Enumerating objects: 11, done.
>  remote: Counting objects: 100% (11/11), done.
>  remote: Total 18 (delta 10), reused 10 (delta 10), pack-reused 7
>  Receiving objects: 100% (18/18), 7.16 KiB | 1.79 MiB/s, done.
>  Resolving deltas: 100% (12/12), completed with 3 local objects.
>  From https://github.com/gitgitgadget/git
>   * [new tag]               pr-590/phil-blain/doc-log-multiple-ranges-v2 -> pr-590/phil-blain/doc-log-multiple-ranges-v2
Oups, I should have tried in a fresh clone...
Show 35 quoted lines
> 
>> Am I reading the documentation correctly ?
>> 
>> tag <tag> syntax [1]:
>> "tag <tag> means the same as refs/tags/<tag>:refs/tags/<tag>; 
>> it requests fetching everything up to the given tag."
>> 
>> --no-tags [2] :
>> "By default, tags that point at objects that are downloaded
>> from the remote repository are fetched and stored locally.
>> This option disables this automatic tag following." 
> 
> I think this last one may be an oversimplification. I'm pretty sure that
> we'd download a tag that points to any object we already have, even if
> it wasn't just fetched.
> 
>  [after this, we'll have the object still, but not the tag]
>  $ git tag -d pr-590/phil-blain/doc-log-multiple-ranges-v2
>  Deleted tag 'pr-590/phil-blain/doc-log-multiple-ranges-v2' (was 3221c3f76f)
> 
>  $ git fetch ggg tag pr-590/phil-blain/doc-log-multiple-ranges-v1
>  remote: Enumerating objects: 16, done.
>  remote: Counting objects: 100% (16/16), done.
>  remote: Total 25 (delta 15), reused 15 (delta 15), pack-reused 9
>  Receiving objects: 100% (25/25), 8.67 KiB | 2.89 MiB/s, done.
>  Resolving deltas: 100% (17/17), completed with 8 local objects.
>  From https://github.com/gitgitgadget/git
>   * [new tag]               pr-590/phil-blain/doc-log-multiple-ranges-v1 -> pr-590/phil-blain/doc-log-multiple-ranges-v1
>   * [new tag]               pr-590/phil-blain/doc-log-multiple-ranges-v2 -> pr-590/phil-blain/doc-log-multiple-ranges-v2
> 
> So in the second fetch, we got v1 and v2, because we already had the
> history for v2 sitting around. In the example at the beginning of my
> email, our git.git clone was pristine. But presumably you ran into this
> in a repository where you'd been doing work on that or other ggg-tracked
> topics.

Yes I think that what happened is I first tried git fetch --tags pr-590/phil-blain/doc-log-multiple-ranges-v1, which fetched all tags, then I deleted the tags but the object stayed, as above, so my next fetch re-created all the tags.

Anyway, sorry for the noise and thanks for you answer!
Philippe.
Previous: Jeff King
Message 3 of 3 in “[BUG?] Fetching a single tag to a local tag requires `--no-tags`”
  1. Philippe BlainJul 15, 2020
  2. Jeff KingJul 15, 2020
  3. Philippe BlainJul 15, 2020

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.