summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 535514f)
raw | patch | inline | side by side (parent: 535514f)
author | Linus Torvalds <torvalds@linux-foundation.org> | |
Fri, 26 Jan 2007 00:51:21 +0000 (16:51 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Fri, 26 Jan 2007 03:16:07 +0000 (19:16 -0800) |
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.
This is because the second one tries to pack only tags; we should
also pack what are already packed -- otherwise we would lose them.
[jc: with an additional test]
Signed-off-by: Junio C Hamano <junkio@cox.net>
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.
This is because the second one tries to pack only tags; we should
also pack what are already packed -- otherwise we would lose them.
[jc: with an additional test]
Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-pack-refs.c | patch | blob | history | |
t/t3210-pack-refs.sh | patch | blob | history |
diff --git a/builtin-pack-refs.c b/builtin-pack-refs.c
index 6de7128b9d8e98dcb9850d9dc932ca522c97473a..3de9b3eefdaad43f0b0212b93055f26a9542533a 100644 (file)
--- a/builtin-pack-refs.c
+++ b/builtin-pack-refs.c
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);
diff --git a/t/t3210-pack-refs.sh b/t/t3210-pack-refs.sh
index 16bdae4f2377cd93a509ff0c74ac62cc00f0b619..f0c7e22b36c66234e2a46bac659506afb454dfa7 100755 (executable)
--- a/t/t3210-pack-refs.sh
+++ b/t/t3210-pack-refs.sh
git-branch -d n/o/p &&
git-branch n'
+test_expect_success 'pack, prune and repack' '
+ git-tag foo &&
+ git-pack-refs --all --prune &&
+ git-show-ref >all-of-them &&
+ git-pack-refs &&
+ git-show-ref >again &&
+ diff all-of-them again
+'
+
test_done