Skip to content

Commit 79e54c6

Browse files
pks-tgitster
authored andcommitted
refs/packed: stop using the_repository
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a6ebc2c commit 79e54c6

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

refs/packed-backend.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#define USE_THE_REPOSITORY_VARIABLE
2-
31
#include "../git-compat-util.h"
42
#include "../config.h"
53
#include "../dir.h"
@@ -794,7 +792,7 @@ static int packed_read_raw_ref(struct ref_store *ref_store, const char *refname,
794792
return -1;
795793
}
796794

797-
if (get_oid_hex(rec, oid))
795+
if (get_oid_hex_algop(rec, oid, ref_store->repo->hash_algo))
798796
die_invalid_line(refs->path, rec, snapshot->eof - rec);
799797

800798
*type = REF_ISPACKED;
@@ -879,7 +877,7 @@ static int next_record(struct packed_ref_iterator *iter)
879877
p = iter->pos;
880878

881879
if (iter->eof - p < snapshot_hexsz(iter->snapshot) + 2 ||
882-
parse_oid_hex(p, &iter->oid, &p) ||
880+
parse_oid_hex_algop(p, &iter->oid, &p, iter->repo->hash_algo) ||
883881
!isspace(*p++))
884882
die_invalid_line(iter->snapshot->refs->path,
885883
iter->pos, iter->eof - iter->pos);
@@ -896,7 +894,7 @@ static int next_record(struct packed_ref_iterator *iter)
896894
if (!refname_is_safe(iter->base.refname))
897895
die("packed refname is dangerous: %s",
898896
iter->base.refname);
899-
oidclr(&iter->oid, the_repository->hash_algo);
897+
oidclr(&iter->oid, iter->repo->hash_algo);
900898
iter->base.flags |= REF_BAD_NAME | REF_ISBROKEN;
901899
}
902900
if (iter->snapshot->peeled == PEELED_FULLY ||
@@ -909,7 +907,7 @@ static int next_record(struct packed_ref_iterator *iter)
909907
if (iter->pos < iter->eof && *iter->pos == '^') {
910908
p = iter->pos + 1;
911909
if (iter->eof - p < snapshot_hexsz(iter->snapshot) + 1 ||
912-
parse_oid_hex(p, &iter->peeled, &p) ||
910+
parse_oid_hex_algop(p, &iter->peeled, &p, iter->repo->hash_algo) ||
913911
*p++ != '\n')
914912
die_invalid_line(iter->snapshot->refs->path,
915913
iter->pos, iter->eof - iter->pos);
@@ -921,13 +919,13 @@ static int next_record(struct packed_ref_iterator *iter)
921919
* we suppress it if the reference is broken:
922920
*/
923921
if ((iter->base.flags & REF_ISBROKEN)) {
924-
oidclr(&iter->peeled, the_repository->hash_algo);
922+
oidclr(&iter->peeled, iter->repo->hash_algo);
925923
iter->base.flags &= ~REF_KNOWS_PEELED;
926924
} else {
927925
iter->base.flags |= REF_KNOWS_PEELED;
928926
}
929927
} else {
930-
oidclr(&iter->peeled, the_repository->hash_algo);
928+
oidclr(&iter->peeled, iter->repo->hash_algo);
931929
}
932930

933931
return ITER_OK;

0 commit comments

Comments
 (0)