Thread (158 messages) 158 messages, 3 authors, 2025-10-16
STALE251d

[PATCH v2 10/49] builtin/repack.c: avoid using `hash_to_hex()` in pack geometry

From: Taylor Blau <hidden>
Date: 2025-10-15 22:27:52
Subsystem: the rest · Maintainer: Linus Torvalds

In previous commits, we started passing either repository or
git_hash_algo pointers around to various spots within builtin/repack.c
to reduce our dependency on the_repository in the hope of undef'ing
USE_THE_REPOSITORY_VARIABLE.

This commit takes us as far as we can (easily) go in that direction by
removing the only use of a convenience function that only exists when
USE_THE_REPOSITORY_VARIABLE is defined.

Unfortunately, the only other such function is "is_bare_repository()",
which is less than straightforward to convert into, say,
"repo_is_bare()", the latter of the two accepting a repository pointer.

Punt on that for now, and declare this commit as the stopping point for
our efforts in the direction of undef'ing USE_THE_REPOSITORY_VARIABLE.

Signed-off-by: Taylor Blau <redacted>
---
 builtin/repack.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/builtin/repack.c b/builtin/repack.c
index a043704aa8..0d35f15b4b 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -683,12 +683,14 @@ static void geometry_remove_redundant_packs(struct pack_geometry *geometry,
 					    struct string_list *names,
 					    struct existing_packs *existing)
 {
+	const struct git_hash_algo *algop = existing->repo->hash_algo;
 	struct strbuf buf = STRBUF_INIT;
 	uint32_t i;
 
 	for (i = 0; i < geometry->split; i++) {
 		struct packed_git *p = geometry->pack[i];
-		if (string_list_has_string(names, hash_to_hex(p->hash)))
+		if (string_list_has_string(names, hash_to_hex_algop(p->hash,
+								    algop)))
 			continue;
 
 		strbuf_reset(&buf);
-- 
2.51.0.540.ga7423965ad8
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help