summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packfile.c15
-rwxr-xr-xt/t5616-partial-clone.sh7
2 files changed, 20 insertions, 2 deletions
diff --git a/packfile.c b/packfile.c
index b79cbc8..1556a5c 100644
--- a/packfile.c
+++ b/packfile.c
@@ -2225,7 +2225,17 @@ static int add_promisor_object(const struct object_id *oid,
void *set_)
{
struct oidset *set = set_;
- struct object *obj = parse_object(the_repository, oid);
+ struct object *obj;
+ int we_parsed_object;
+
+ obj = lookup_object(the_repository, oid);
+ if (obj && obj->parsed) {
+ we_parsed_object = 0;
+ } else {
+ we_parsed_object = 1;
+ obj = parse_object(the_repository, oid);
+ }
+
if (!obj)
return 1;
@@ -2247,7 +2257,8 @@ static int add_promisor_object(const struct object_id *oid,
return 0;
while (tree_entry_gently(&desc, &entry))
oidset_insert(set, &entry.oid);
- free_tree_buffer(tree);
+ if (we_parsed_object)
+ free_tree_buffer(tree);
} else if (obj->type == OBJ_COMMIT) {
struct commit *commit = (struct commit *) obj;
struct commit_list *parents = commit->parents;
diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
index 5cb4153..9c0e422 100755
--- a/t/t5616-partial-clone.sh
+++ b/t/t5616-partial-clone.sh
@@ -49,6 +49,13 @@ test_expect_success 'do partial clone 1' '
test "$(git -C pc1 config --local remote.origin.partialclonefilter)" = "blob:none"
'
+test_expect_success 'rev-list --missing=allow-promisor on partial clone' '
+ git -C pc1 rev-list --objects --missing=allow-promisor HEAD >actual &&
+ git -C pc1 rev-list --objects --missing=print HEAD >expect.raw &&
+ grep -v "^?" expect.raw >expect &&
+ test_cmp expect actual
+'
+
test_expect_success 'verify that .promisor file contains refs fetched' '
ls pc1/.git/objects/pack/pack-*.promisor >promisorlist &&
test_line_count = 1 promisorlist &&