Skip to content

Commit c07173f

Browse files
committed
Merge branch 'jk/maint-for-each-packed-object'
The for_each_packed_object() API function did not iterate over objects in a packfile that hasn't been used yet. * jk/maint-for-each-packed-object: for_each_packed_object: automatically open pack index
2 parents 0bf46af + f813e9e commit c07173f

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

sha1_file.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3575,14 +3575,19 @@ int for_each_packed_object(each_packed_object_fn cb, void *data, unsigned flags)
35753575
{
35763576
struct packed_git *p;
35773577
int r = 0;
3578+
int pack_errors = 0;
35783579

35793580
prepare_packed_git();
35803581
for (p = packed_git; p; p = p->next) {
35813582
if ((flags & FOR_EACH_OBJECT_LOCAL_ONLY) && !p->pack_local)
35823583
continue;
3584+
if (open_pack_index(p)) {
3585+
pack_errors = 1;
3586+
continue;
3587+
}
35833588
r = for_each_object_in_pack(p, cb, data);
35843589
if (r)
35853590
break;
35863591
}
3587-
return r;
3592+
return r ? r : pack_errors;
35883593
}

t/t5304-prune.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ test_expect_success 'gc: prune old objects after local clone' '
218218
'
219219

220220
test_expect_success 'garbage report in count-objects -v' '
221+
test_when_finished "rm -f .git/objects/pack/fake*" &&
221222
: >.git/objects/pack/foo &&
222223
: >.git/objects/pack/foo.bar &&
223224
: >.git/objects/pack/foo.keep &&

0 commit comments

Comments
 (0)