All of lore.kernel.org
 help / color / mirror / Atom feed
From: "René Scharfe" <l.s.r@web.de>
To: Git List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>
Subject: [PATCH 3/5] packfile: convert mark_bad_packed_object() to object_id
Date: Sat, 11 Sep 2021 22:40:33 +0200	[thread overview]
Message-ID: <a6d7114f-08c1-567a-d8d4-40becd2384f6@web.de> (raw)
In-Reply-To: <e50c1465-59de-7fe1-de01-800404c7640e@web.de>

All callers have full object IDs, so pass them on instead of just their
hash member.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 object-file.c |  2 +-
 packfile.c    | 12 ++++++------
 packfile.h    |  2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/object-file.c b/object-file.c
index a8be899481..fb5a385a06 100644
--- a/object-file.c
+++ b/object-file.c
@@ -1616,7 +1616,7 @@ static int do_oid_object_info_extended(struct repository *r,
 		return 0;
 	rtype = packed_object_info(r, e.p, e.offset, oi);
 	if (rtype < 0) {
-		mark_bad_packed_object(e.p, real->hash);
+		mark_bad_packed_object(e.p, real);
 		return do_oid_object_info_extended(r, real, oi, 0);
 	} else if (oi->whence == OI_PACKED) {
 		oi->u.packed.offset = e.offset;
diff --git a/packfile.c b/packfile.c
index 4d0d625238..fb15fc5b49 100644
--- a/packfile.c
+++ b/packfile.c
@@ -1161,17 +1161,17 @@ int unpack_object_header(struct packed_git *p,
 	return type;
 }

-void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1)
+void mark_bad_packed_object(struct packed_git *p, const struct object_id *oid)
 {
 	unsigned i;
 	const unsigned hashsz = the_hash_algo->rawsz;
 	for (i = 0; i < p->num_bad_objects; i++)
-		if (hasheq(sha1, p->bad_object_sha1 + hashsz * i))
+		if (hasheq(oid->hash, p->bad_object_sha1 + hashsz * i))
 			return;
 	p->bad_object_sha1 = xrealloc(p->bad_object_sha1,
 				      st_mult(GIT_MAX_RAWSZ,
 					      st_add(p->num_bad_objects, 1)));
-	hashcpy(p->bad_object_sha1 + hashsz * p->num_bad_objects, sha1);
+	hashcpy(p->bad_object_sha1 + hashsz * p->num_bad_objects, oid->hash);
 	p->num_bad_objects++;
 }

@@ -1272,7 +1272,7 @@ static int retry_bad_packed_offset(struct repository *r,
 	if (offset_to_pack_pos(p, obj_offset, &pos) < 0)
 		return OBJ_BAD;
 	nth_packed_object_id(&oid, p, pack_pos_to_index(p, pos));
-	mark_bad_packed_object(p, oid.hash);
+	mark_bad_packed_object(p, &oid);
 	type = oid_object_info(r, &oid, NULL);
 	if (type <= OBJ_NONE)
 		return OBJ_BAD;
@@ -1722,7 +1722,7 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
 				nth_packed_object_id(&oid, p, index_pos);
 				error("bad packed object CRC for %s",
 				      oid_to_hex(&oid));
-				mark_bad_packed_object(p, oid.hash);
+				mark_bad_packed_object(p, &oid);
 				data = NULL;
 				goto out;
 			}
@@ -1811,7 +1811,7 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
 				      " at offset %"PRIuMAX" from %s",
 				      oid_to_hex(&base_oid), (uintmax_t)obj_offset,
 				      p->pack_name);
-				mark_bad_packed_object(p, base_oid.hash);
+				mark_bad_packed_object(p, &base_oid);
 				base = read_object(r, &base_oid, &type, &base_size);
 				external_base = base;
 			}
diff --git a/packfile.h b/packfile.h
index 3ae117a8ae..a982ed9994 100644
--- a/packfile.h
+++ b/packfile.h
@@ -159,7 +159,7 @@ int packed_object_info(struct repository *r,
 		       struct packed_git *pack,
 		       off_t offset, struct object_info *);

-void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1);
+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);

 #define ON_DISK_KEEP_PACKS 1
--
2.33.0

  parent reply	other threads:[~2021-09-11 20:40 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-11  7:50 [PATCH 0/3] packfile: use oidset for bad objects René Scharfe
2021-09-11  7:59 ` [PATCH 1/3] packfile: convert mark_bad_packed_object() to object_id René Scharfe
2021-09-11  8:00 ` [PATCH 2/3] packfile: convert has_packed_and_bad() " René Scharfe
2021-09-11  8:01 ` [PATCH 3/3] packfile: use oidset for bad objects René Scharfe
2021-09-11 14:26   ` Jeff King
2021-09-11 16:08     ` René Scharfe
2021-09-11 17:03       ` Jeff King
2021-09-11 17:16         ` René Scharfe
2021-09-11 14:27 ` [PATCH 0/3] " Jeff King
2021-09-11 16:08 ` [PATCH 4/3] midx: inline nth_midxed_pack_entry() René Scharfe
2021-09-11 17:03   ` René Scharfe
2021-09-11 17:07   ` Jeff King
2021-09-11 20:31     ` René Scharfe
2021-09-11 21:20       ` Jeff King
2021-09-11 23:39         ` René Scharfe
2021-09-11 20:31 ` [PATCH v2 0/5] packfile: use oidset for bad objects René Scharfe
2021-09-11 20:36   ` [PATCH 1/5] oidset: make oidset_size() an inline function René Scharfe
2021-09-11 20:39   ` [PATCH 2/5] midx: inline nth_midxed_pack_entry() René Scharfe
2021-09-11 20:40   ` René Scharfe [this message]
2021-09-11 20:42   ` [PATCH v2 4/5] packfile: convert has_packed_and_bad() to object_id René Scharfe
2021-09-11 20:43   ` [PATCH v2 5/5] packfile: use oidset for bad objects René Scharfe
2021-09-11 20:45   ` [PATCH v2 0/5] " René Scharfe
2021-09-11 21:22   ` Jeff King
2021-09-11 23:59   ` Derrick Stolee
2021-09-12  1:51     ` Taylor Blau
2021-09-12  2:29       ` Taylor Blau
2021-09-12  3:51         ` Derrick Stolee
2021-09-12  4:01           ` Taylor Blau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a6d7114f-08c1-567a-d8d4-40becd2384f6@web.de \
    --to=l.s.r@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.