Browse Source

packfile: allow has_packed_and_bad to handle arbitrary repositories

has_packed_and_bad is not widely used, so just migrate it all at once.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Stefan Beller 6 years ago committed by Junio C Hamano
parent
commit
33b94066f2
  1. 5
      packfile.c
  2. 2
      packfile.h
  3. 2
      sha1-file.c

5
packfile.c

@ -1131,12 +1131,13 @@ void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1) @@ -1131,12 +1131,13 @@ void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1)
p->num_bad_objects++;
}

const struct packed_git *has_packed_and_bad(const unsigned char *sha1)
const struct packed_git *has_packed_and_bad(struct repository *r,
const unsigned char *sha1)
{
struct packed_git *p;
unsigned i;

for (p = the_repository->objects->packed_git; p; p = p->next)
for (p = r->objects->packed_git; p; p = p->next)
for (i = 0; i < p->num_bad_objects; i++)
if (hasheq(sha1,
p->bad_object_sha1 + the_hash_algo->rawsz * i))

2
packfile.h

@ -146,7 +146,7 @@ extern int packed_object_info(struct repository *r, @@ -146,7 +146,7 @@ extern int packed_object_info(struct repository *r,
off_t offset, struct object_info *);

extern void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1);
extern const struct packed_git *has_packed_and_bad(const unsigned char *sha1);
extern const struct packed_git *has_packed_and_bad(struct repository *r, const unsigned char *sha1);

/*
* Iff a pack file in the given repository contains the object named by sha1,

2
sha1-file.c

@ -1432,7 +1432,7 @@ void *read_object_file_extended(const struct object_id *oid, @@ -1432,7 +1432,7 @@ void *read_object_file_extended(const struct object_id *oid,
die(_("loose object %s (stored in %s) is corrupt"),
oid_to_hex(repl), path);

if ((p = has_packed_and_bad(repl->hash)) != NULL)
if ((p = has_packed_and_bad(the_repository, repl->hash)) != NULL)
die(_("packed object %s (stored in %s) is corrupt"),
oid_to_hex(repl), p->pack_name);


Loading…
Cancel
Save