summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 869a3d3)
raw | patch | inline | side by side (parent: 869a3d3)
author | Brandon Casey <drafnel@gmail.com> | |
Sat, 21 Mar 2009 22:26:11 +0000 (17:26 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 22 Mar 2009 04:58:44 +0000 (21:58 -0700) |
If pack-objects is called with the --unpack-unreachable option then it
will unpack (i.e. loosen) all unreferenced objects from local not-kept
packs, including those that also exist in packs residing in an alternate
object database or a locally kept pack. The only user of this option is
git-repack.
In this case, repack will follow the call to pack-objects with a call to
prune-packed, which will delete these newly loosened objects, making the
act of loosening a waste of time. The unnecessary loosening can be
avoided by checking whether an object exists in a non-local pack or a
locally kept pack before loosening it.
This fixes the 'local packed unreachable obs that exist in alternate ODB
are not loosened' test in t7700.
Signed-off-by: Brandon Casey <drafnel@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
will unpack (i.e. loosen) all unreferenced objects from local not-kept
packs, including those that also exist in packs residing in an alternate
object database or a locally kept pack. The only user of this option is
git-repack.
In this case, repack will follow the call to pack-objects with a call to
prune-packed, which will delete these newly loosened objects, making the
act of loosening a waste of time. The unnecessary loosening can be
avoided by checking whether an object exists in a non-local pack or a
locally kept pack before loosening it.
This fixes the 'local packed unreachable obs that exist in alternate ODB
are not loosened' test in t7700.
Signed-off-by: Brandon Casey <drafnel@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-pack-objects.c | patch | blob | history | |
t/t7700-repack.sh | patch | blob | history |
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 6222f19c7887658d872a4b096ec8dc4988669107..ad3f8e7751a8de2697288966a39ce54abd7b3242 100644 (file)
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
free(in_pack.array);
}
+static int has_sha1_pack_kept_or_nonlocal(const unsigned char *sha1)
+{
+ static struct packed_git *last_found = (void *)1;
+ struct packed_git *p;
+
+ p = (last_found != (void *)1) ? last_found : packed_git;
+
+ while (p) {
+ if ((!p->pack_local || p->pack_keep) &&
+ find_pack_entry_one(sha1, p)) {
+ last_found = p;
+ return 1;
+ }
+ if (p == last_found)
+ p = packed_git;
+ else
+ p = p->next;
+ if (p == last_found)
+ p = p->next;
+ }
+ return 0;
+}
+
static void loosen_unused_packed_objects(struct rev_info *revs)
{
struct packed_git *p;
for (i = 0; i < p->num_objects; i++) {
sha1 = nth_packed_object_sha1(p, i);
- if (!locate_object_entry(sha1))
+ if (!locate_object_entry(sha1) &&
+ !has_sha1_pack_kept_or_nonlocal(sha1))
if (force_object_loose(sha1, p->mtime))
die("unable to force loose object");
}
diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh
index 013e488bddde2ba8f26da4171550f2667fc0c001..9ce546e3b225563279c54eb6ceafd87398a3e5cc 100755 (executable)
--- a/t/t7700-repack.sh
+++ b/t/t7700-repack.sh
@@ -113,7 +113,7 @@ test_expect_success 'packed unreachable obs in alternate ODB are not loosened' '
test_must_fail git show $csha1
'
-test_expect_failure 'local packed unreachable obs that exist in alternate ODB are not loosened' '
+test_expect_success 'local packed unreachable obs that exist in alternate ODB are not loosened' '
echo `pwd`/alt_objects > .git/objects/info/alternates &&
echo "$csha1" | git pack-objects --non-empty --all --reflog pack &&
rm -f .git/objects/pack/* &&