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

[PATCH] Do not fetch tags on new shallow clones

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jan 4, 2012, 11:35 UTC
Message-ID
<1325676922-6995-1-git-send-email-pclouds@gmail.com>

The main purpose of shallow clones is to reduce download. Fetching tags likely defeats this purpose because old-enough repos tend to have a lot of tags, spreading across history, which may increase the number of objects to download significantly.

For example, "git clone --depth=10 git://.../git.git" without changes fetches ~16M (50k objects). The same command with changes fetches ~6.5M (10k objects).

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 This could also be applied for normal clones. But I don't think
 there are many use cases for it, enough to deserve new --no-tags
 option.
 We should also fetch a single branch, but because branches are
 usually less crowded and stay close the tip, they do not produce too
 many extra objects. Let's leave it until somebody yells up.
 We should also fetch tags that reference to downloaded objects. But I
 don't know how fetch does that magic, so for now users have to do
 "git fetch" after cloning for tags. I have only gone as far as
 fetching tags along by setting TRANS_OPT_FOLLOWTAGS? Help?
 builtin/clone.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/builtin/clone.c b/builtin/clone.c
index 86db954..abd8578 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -428,7 +428,7 @@ static struct ref *wanted_peer_refs(const struct ref *refs,
 	struct ref **tail = head ? &head->next : &local_refs;
 
 	get_fetch_map(refs, refspec, &tail, 0);
-	if (!option_mirror)
+	if (!option_mirror && !option_depth)
 		get_fetch_map(refs, tag_refspec, &tail, 0);
 
 	return local_refs;
-- 
1.7.8.36.g69ee2
Next: Shawn Pearce
Message 1 of 12 in “Do not fetch tags on new shallow clones”
  1. Do not fetch tags on new shallow clonesNguyễn Thái Ngọc Duy, Jan 4, 2012
  2. Shawn PearceJan 4, 2012
  3. Junio C HamanoJan 4, 2012
  4. Shawn PearceJan 5, 2012
  5. Junio C HamanoJan 5, 2012
  6. Shawn PearceJan 5, 2012
  7. Limit refs to fetch to minimum in shallow clonesNguyễn Thái Ngọc Duy, Jan 5, 2012
  8. Junio C HamanoJan 5, 2012
  9. Limit refs to fetch to minimum in shallow clonesNguyễn Thái Ngọc Duy, Jan 6, 2012
  10. Junio C HamanoJan 6, 2012
  11. Nguyen Thai Ngoc DuyJan 7, 2012
  12. clone: add --single-branch to fetch only one branchNguyễn Thái Ngọc Duy, Jan 7, 2012

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.