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

Seriously broken "git pack-refs"

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Jan 26, 2007, 00:51 UTC
Message-ID
<Pine.LNX.4.64.0701251636060.25027@woody.linux-foundation.org>
Do *NOT* try this on a repository you care about:
	git pack-refs --all --prune
	git pack-refs

because while the first "pack-refs" does the right thing, the second pack-refs will totally screw you over.

Why? 

The default for "git pack-refs" is to pack just tags. Which is a HORRIBLE MISTAKE. Becuase it means that if you actually had any packed non-tags, they now get removed entirely.

I'd call whoever made that decision a complete crack-addict and total idiot, but it might be me, so I'll just tread carefully and call the choice "interesting".

This should fix it.
		Linus
----
diff --git a/builtin-pack-refs.c b/builtin-pack-refs.c
index 6de7128..3de9b3e 100644
--- a/builtin-pack-refs.c
+++ b/builtin-pack-refs.c
@@ -37,7 +37,9 @@ static int handle_one_ref(const char *path, const unsigned char *sha1,
 	if ((flags & REF_ISSYMREF))
 		return 0;
 	is_tag_ref = !strncmp(path, "refs/tags/", 10);
-	if (!cb->all && !is_tag_ref)
+
+	/* ALWAYS pack refs that were already packed or are tags */
+	if (!cb->all && !is_tag_ref && !(flags & REF_ISPACKED))
 		return 0;
 
 	fprintf(cb->refs_file, "%s %s\n", sha1_to_hex(sha1), path);
Next: Junio C Hamano
Message 1 of 6 in “Seriously broken "git pack-refs"”
  1. Linus TorvaldsJan 26, 2007
  2. Junio C HamanoJan 26, 2007
  3. Linus TorvaldsJan 26, 2007
  4. Junio C HamanoJan 26, 2007
  5. Linus TorvaldsJan 26, 2007
  6. Junio C HamanoJan 26, 2007

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.