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

Re: Shallow clone

From
AJAlexandre Julliard <julliard@winehq.org>
Date
Nov 11, 2006, 13:57 UTC
Message-ID
<87zmaynl18.fsf@wine.dyndns.org>
In-Reply-To
<7vac31p8om.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> writes:
Show 6 quoted lines
> But it seems to need some more work.  I just tried to clone
> git.git with --depth=1 and it cauterizes each branch with two
> commits (I think that is what depth=1 means -- the latest and
> one behind it), but it pulled almost the whole repository
> anyway, and it turns out that "git log v1.4.3-rc1" gives me the
> full history leading to it.

That's apparently because tags are not considered when truncating the commit list. The patch below fixes it, and fetches the right number of commits for each tag. However the correct fix is probably to not fetch historical tags at all.

There's also a problem with the packing, a clone --depth 1 currently results in a pack that's about 3 times as large as it should be.

---
diff --git a/shallow.c b/shallow.c
index 58a7b20..2db1dc4 100644
--- a/shallow.c
+++ b/shallow.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "commit.h"
+#include "tag.h"
 
 static int is_shallow = -1;
 
@@ -54,7 +55,7 @@ struct commit_list *get_shallow_commits(
 		if (!commit) {
 			if (i < heads->nr) {
 				commit = (struct commit *)
-					heads->objects[i++].item;
+					deref_tag(heads->objects[i++].item, NULL, 0);
 				if (commit->object.type != OBJ_COMMIT) {
 					commit = NULL;
 					continue;
-- 
Alexandre Julliard
Previous: Aneesh KumarNext: Junio C Hamano
Message 7 of 20 in “What's in git.git”
  1. Junio C HamanoNov 8, 2006
  2. David LangNov 8, 2006
  3. Shallow clone [Was Re: What's in git.git ]Aneesh Kumar K.V, Nov 8, 2006
  4. Aneesh Kumar K.VNov 8, 2006
  5. Junio C HamanoNov 9, 2006
  6. Aneesh KumarNov 9, 2006
  7. Alexandre JulliardNov 11, 2006
  8. Junio C HamanoNov 12, 2006
  9. Sergey VlasovNov 12, 2006
  10. Junio C HamanoNov 12, 2006
  11. Junio C HamanoNov 13, 2006
  12. Petr BaudisNov 12, 2006
  13. Junio C HamanoNov 12, 2006
  14. Johannes SchindelinNov 12, 2006
  15. Jakub NarebskiNov 8, 2006
  16. Junio C HamanoNov 8, 2006
  17. Jakub NarebskiNov 8, 2006
  18. Junio C HamanoNov 8, 2006
  19. Petr BaudisNov 8, 2006
  20. Junio C HamanoNov 9, 2006

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.