Seriously broken "git pack-refs"

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2016-06-15 22:42:51
Subsystem: the rest · Maintainer: Linus Torvalds

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);
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help