Thread (28 messages) flat view 28 messages, 4 authors, 2021-09-12
STALE1820d

Revision v2 of 2 in this series.

Revisions (2)
  1. v1 [diff vs current]
  2. v2 current

[PATCH v2 4/5] packfile: convert has_packed_and_bad() to object_id

From: René Scharfe <hidden>
Date: 2021-09-11 20:42:29
Subsystem: the rest · Maintainer: Linus Torvalds

The single caller has a full object ID, so pass it on instead of just
its hash member.

Signed-off-by: René Scharfe <redacted>
---
 object-file.c | 2 +-
 packfile.c    | 4 ++--
 packfile.h    | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/object-file.c b/object-file.c
index fb5a385a06..01e7058b4e 100644
--- a/object-file.c
+++ b/object-file.c
@@ -1725,7 +1725,7 @@ void *read_object_file_extended(struct repository *r,
 		die(_("loose object %s (stored in %s) is corrupt"),
 		    oid_to_hex(repl), path);

-	if ((p = has_packed_and_bad(r, repl->hash)) != NULL)
+	if ((p = has_packed_and_bad(r, repl)) != NULL)
 		die(_("packed object %s (stored in %s) is corrupt"),
 		    oid_to_hex(repl), p->pack_name);
 	obj_read_unlock();
diff --git a/packfile.c b/packfile.c
index fb15fc5b49..04080a558b 100644
--- a/packfile.c
+++ b/packfile.c
@@ -1176,14 +1176,14 @@ void mark_bad_packed_object(struct packed_git *p, const struct object_id *oid)
 }

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

 	for (p = r->objects->packed_git; p; p = p->next)
 		for (i = 0; i < p->num_bad_objects; i++)
-			if (hasheq(sha1,
+			if (hasheq(oid->hash,
 				   p->bad_object_sha1 + the_hash_algo->rawsz * i))
 				return p;
 	return NULL;
diff --git a/packfile.h b/packfile.h
index a982ed9994..186146779d 100644
--- a/packfile.h
+++ b/packfile.h
@@ -160,7 +160,7 @@ int packed_object_info(struct repository *r,
 		       off_t offset, struct object_info *);

 void mark_bad_packed_object(struct packed_git *, const struct object_id *);
-const struct packed_git *has_packed_and_bad(struct repository *r, const unsigned char *sha1);
+const struct packed_git *has_packed_and_bad(struct repository *, const struct object_id *);

 #define ON_DISK_KEEP_PACKS 1
 #define IN_CORE_KEEP_PACKS 2
--
2.33.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help