git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Bagas Sanjaya <bagasdotme@gmail.com>
To: Git Users <git@vger.kernel.org>
Subject: Fetching single tag in shallow clone almost unshallow the clone
Date: Fri, 28 May 2021 14:03:05 +0700	[thread overview]
Message-ID: <304633fd-e677-7956-6787-f60f195db9b5@gmail.com> (raw)

Hi,

I have a copy of Golang repository [1] on my local Git server on my 
computer. I'm experimenting with fetching single tags in shallow
clone.

I begin with shallow clone the repo:

$ git clone https://<myhost>/path/to/go.git --depth 200 golang
$ cd golang

Because only one, default branch (master) is checked out on shallow 
clone, I fetch latest release branch shallowly:

$ git remote set-branches --add origin release-branch.go1.16
$ git fetch origin release-branch.go1.16 --depth 25

Then I fetch single tag only, that is latest tagged release:

$ git fetch origin tag go1.16.4 --no-tags
> From https://<myhost>/path/to/go
>  * [new tag]           go1.16.4   -> go1.16.4

That above worked, because the commit the tag refers to is already on 
the clone.

But when I fetch a single tag which the commit the tag refers to isn't 
already on the clone, Git fetched almost the entire history (thus almost 
unshallow the clone):

$ git fetch origin tag go1.16.1 --no-tags
> remote: Enumerating objects: 436644, done.
> remote: Counting objects: 100% (427655/427655), done.
> remote: Compressing objects: 100% (75334/75334), done.
> remote: Total 419698 (delta 343975), reused 416121 (delta 341201), pack-reused 0
> Receiving objects: 100% (419698/419698), 146.94 MiB | 16.06 MiB/s, done.
> Resolving deltas: 100% (343975/343975), completed with 4892 local objects.
> From https://gitnode.io/bagas/go
>  * [new tag]           go1.16.1   -> go1.16.1

I expect that instead Git will deepen the shallow clone until the 
specified tag.

Note that I used "almost unshallow" phrase, because although almost the 
whole history had been fetched, `.git/shallow` still exists, meant that 
the clone was still shallow. To convert to full clone, I did `git fetch 
--unshallow`, which also fetched tags referenced on either master or 
already configured released branches.

Thanks.

[1]: https://github.com/golang/go
-- 
An old man doll... just what I always wanted! - Clara

             reply	other threads:[~2021-05-28  7:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-28  7:03 Bagas Sanjaya [this message]
2021-05-28 11:40 ` Fetching single tag in shallow clone almost unshallow the clone Derrick Stolee
2021-05-28 12:46   ` Bagas Sanjaya

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=304633fd-e677-7956-6787-f60f195db9b5@gmail.com \
    --to=bagasdotme@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).