Thread (175 messages) 175 messages, 5 authors, 2024-12-03
STALE568d
Revisions (10)
  1. v1 current
  2. v2 [diff vs current]
  3. v3 [diff vs current]
  4. v4 [diff vs current]
  5. v5 [diff vs current]
  6. v6 [diff vs current]
  7. v7 [diff vs current]
  8. v8 [diff vs current]
  9. v9 [diff vs current]
  10. v10 [diff vs current]

[PATCH 08/20] packfile: pass down repository to `unpack_compressed_entry`

From: Karthik Nayak <hidden>
Date: 2024-10-21 09:58:14
Subsystem: the rest · Maintainer: Linus Torvalds

The function `unpack_compressed_entry` currently relies on the global
variable `the_repository`. To eliminate global variable usage in
`packfile.c`, we should progressively shift the dependency on
the_repository to higher layers. Let's remove its usage from this
function.

Signed-off-by: Karthik Nayak <redacted>
---
 packfile.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/packfile.c b/packfile.c
index 458db59b3a..54f3b9f0a7 100644
--- a/packfile.c
+++ b/packfile.c
@@ -1615,10 +1615,11 @@ int packed_object_info(struct repository *r, struct packed_git *p,
 	return type;
 }
 
-static void *unpack_compressed_entry(struct packed_git *p,
-				    struct pack_window **w_curs,
-				    off_t curpos,
-				    unsigned long size)
+static void *unpack_compressed_entry(struct repository *repo,
+				     struct packed_git *p,
+				     struct pack_window **w_curs,
+				     off_t curpos,
+				     unsigned long size)
 {
 	int st;
 	git_zstream stream;
@@ -1633,8 +1634,7 @@ static void *unpack_compressed_entry(struct packed_git *p,
 
 	git_inflate_init(&stream);
 	do {
-		in = use_pack(the_repository, p, w_curs, curpos,
-			      &stream.avail_in);
+		in = use_pack(repo, p, w_curs, curpos, &stream.avail_in);
 		stream.next_in = in;
 		/*
 		 * Note: we must ensure the window section returned by
@@ -1777,7 +1777,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
 	case OBJ_BLOB:
 	case OBJ_TAG:
 		if (!base_from_cache)
-			data = unpack_compressed_entry(p, &w_curs, curpos, size);
+			data = unpack_compressed_entry(r, p, &w_curs, curpos,
+						       size);
 		break;
 	default:
 		data = NULL;
@@ -1838,7 +1839,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
 		if (!base)
 			continue;
 
-		delta_data = unpack_compressed_entry(p, &w_curs, curpos, delta_size);
+		delta_data = unpack_compressed_entry(r, p, &w_curs, curpos,
+						     delta_size);
 
 		if (!delta_data) {
 			error("failed to unpack compressed delta "
-- 
2.47.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