diff mbox series

[4/5] refs/packed: stop using `the_repository`

Message ID d164cd3aa12b67ba98c9b878543497482441ba2c.1722316795.git.ps@pks.im (mailing list archive)
State Accepted
Commit 79e54c6a4ed0e091909ffd6754d795b113c33a76
Headers show
Series refs: stop using `the_repository` | expand

Commit Message

Patrick Steinhardt July 30, 2024, 5:23 a.m. UTC
Convert the packed ref backend to stop using `the_repository` in favor
of the repo that gets passed in via `struct ref_store`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 refs/packed-backend.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

Comments

karthik nayak July 30, 2024, 11:23 a.m. UTC | #1
Patrick Steinhardt <ps@pks.im> writes:

> Convert the packed ref backend to stop using `the_repository` in favor
> of the repo that gets passed in via `struct ref_store`.
>

Nit: Might be nice to add that we move to using `get_oid_hex_algop` in
this commit. Since it was also mentioned in a prev commit

[snip]
Patrick Steinhardt July 31, 2024, 4:59 a.m. UTC | #2
On Tue, Jul 30, 2024 at 07:23:55AM -0400, Karthik Nayak wrote:
> Patrick Steinhardt <ps@pks.im> writes:
> 
> > Convert the packed ref backend to stop using `the_repository` in favor
> > of the repo that gets passed in via `struct ref_store`.
> >
> 
> Nit: Might be nice to add that we move to using `get_oid_hex_algop` in
> this commit. Since it was also mentioned in a prev commit

Yeah, that'd make sense indeed. I'll refrain from sending out a new
version of this patch series just to amend the commit message, but have
queued the change locally and will send it out in case any other changes
are required for this patch series.

Thanks!

Patrick
diff mbox series

Patch

diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index a0666407cd..89976aa359 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -1,5 +1,3 @@ 
-#define USE_THE_REPOSITORY_VARIABLE
-
 #include "../git-compat-util.h"
 #include "../config.h"
 #include "../dir.h"
@@ -794,7 +792,7 @@  static int packed_read_raw_ref(struct ref_store *ref_store, const char *refname,
 		return -1;
 	}
 
-	if (get_oid_hex(rec, oid))
+	if (get_oid_hex_algop(rec, oid, ref_store->repo->hash_algo))
 		die_invalid_line(refs->path, rec, snapshot->eof - rec);
 
 	*type = REF_ISPACKED;
@@ -879,7 +877,7 @@  static int next_record(struct packed_ref_iterator *iter)
 	p = iter->pos;
 
 	if (iter->eof - p < snapshot_hexsz(iter->snapshot) + 2 ||
-	    parse_oid_hex(p, &iter->oid, &p) ||
+	    parse_oid_hex_algop(p, &iter->oid, &p, iter->repo->hash_algo) ||
 	    !isspace(*p++))
 		die_invalid_line(iter->snapshot->refs->path,
 				 iter->pos, iter->eof - iter->pos);
@@ -896,7 +894,7 @@  static int next_record(struct packed_ref_iterator *iter)
 		if (!refname_is_safe(iter->base.refname))
 			die("packed refname is dangerous: %s",
 			    iter->base.refname);
-		oidclr(&iter->oid, the_repository->hash_algo);
+		oidclr(&iter->oid, iter->repo->hash_algo);
 		iter->base.flags |= REF_BAD_NAME | REF_ISBROKEN;
 	}
 	if (iter->snapshot->peeled == PEELED_FULLY ||
@@ -909,7 +907,7 @@  static int next_record(struct packed_ref_iterator *iter)
 	if (iter->pos < iter->eof && *iter->pos == '^') {
 		p = iter->pos + 1;
 		if (iter->eof - p < snapshot_hexsz(iter->snapshot) + 1 ||
-		    parse_oid_hex(p, &iter->peeled, &p) ||
+		    parse_oid_hex_algop(p, &iter->peeled, &p, iter->repo->hash_algo) ||
 		    *p++ != '\n')
 			die_invalid_line(iter->snapshot->refs->path,
 					 iter->pos, iter->eof - iter->pos);
@@ -921,13 +919,13 @@  static int next_record(struct packed_ref_iterator *iter)
 		 * we suppress it if the reference is broken:
 		 */
 		if ((iter->base.flags & REF_ISBROKEN)) {
-			oidclr(&iter->peeled, the_repository->hash_algo);
+			oidclr(&iter->peeled, iter->repo->hash_algo);
 			iter->base.flags &= ~REF_KNOWS_PEELED;
 		} else {
 			iter->base.flags |= REF_KNOWS_PEELED;
 		}
 	} else {
-		oidclr(&iter->peeled, the_repository->hash_algo);
+		oidclr(&iter->peeled, iter->repo->hash_algo);
 	}
 
 	return ITER_OK;