aboutsummaryrefslogtreecommitdiffstats
path: root/refs
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-10-30 15:43:42 +0900
committerJunio C Hamano <gitster@pobox.com>2018-10-30 15:43:42 +0900
commitd829d491eebddc2eefcaa9279ac4b67c7eefbd52 (patch)
treecb639ce3f677d995b42a3537d00ee74b8b4797c6 /refs
parent7dc3e5a3be73cf0cbb5f3af6d8e3bb10c70cca3e (diff)
parent0d7c419a94b7524ac854d5a6002b7541abab4f12 (diff)
downloadgit-d829d491eebddc2eefcaa9279ac4b67c7eefbd52.tar.gz
Merge branch 'bc/hash-transition-part-15'
More codepaths are moving away from hardcoded hash sizes. * bc/hash-transition-part-15: rerere: convert to use the_hash_algo submodule: make zero-oid comparison hash function agnostic apply: rename new_sha1_prefix and old_sha1_prefix apply: replace hard-coded constants tag: express constant in terms of the_hash_algo transport: use parse_oid_hex instead of a constant upload-pack: express constants in terms of the_hash_algo refs/packed-backend: express constants using the_hash_algo packfile: express constants in terms of the_hash_algo pack-revindex: express constants in terms of the_hash_algo builtin/fetch-pack: remove constants with parse_oid_hex builtin/mktree: remove hard-coded constant builtin/repack: replace hard-coded constants pack-bitmap-write: use GIT_MAX_RAWSZ for allocation object_id.cocci: match only expressions of type 'struct object_id'
Diffstat (limited to 'refs')
-rw-r--r--refs/packed-backend.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index 74e2996e93..c01c7f5901 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -274,8 +274,8 @@ struct snapshot_record {
static int cmp_packed_ref_records(const void *v1, const void *v2)
{
const struct snapshot_record *e1 = v1, *e2 = v2;
- const char *r1 = e1->start + GIT_SHA1_HEXSZ + 1;
- const char *r2 = e2->start + GIT_SHA1_HEXSZ + 1;
+ const char *r1 = e1->start + the_hash_algo->hexsz + 1;
+ const char *r2 = e2->start + the_hash_algo->hexsz + 1;
while (1) {
if (*r1 == '\n')
@@ -297,7 +297,7 @@ static int cmp_packed_ref_records(const void *v1, const void *v2)
*/
static int cmp_record_to_refname(const char *rec, const char *refname)
{
- const char *r1 = rec + GIT_SHA1_HEXSZ + 1;
+ const char *r1 = rec + the_hash_algo->hexsz + 1;
const char *r2 = refname;
while (1) {
@@ -344,7 +344,7 @@ static void sort_snapshot(struct snapshot *snapshot)
if (!eol)
/* The safety check should prevent this. */
BUG("unterminated line found in packed-refs");
- if (eol - pos < GIT_SHA1_HEXSZ + 2)
+ if (eol - pos < the_hash_algo->hexsz + 2)
die_invalid_line(snapshot->refs->path,
pos, eof - pos);
eol++;
@@ -456,7 +456,7 @@ static void verify_buffer_safe(struct snapshot *snapshot)
return;
last_line = find_start_of_record(start, eof - 1);
- if (*(eof - 1) != '\n' || eof - last_line < GIT_SHA1_HEXSZ + 2)
+ if (*(eof - 1) != '\n' || eof - last_line < the_hash_algo->hexsz + 2)
die_invalid_line(snapshot->refs->path,
last_line, eof - last_line);
}
@@ -796,7 +796,7 @@ static int next_record(struct packed_ref_iterator *iter)
iter->base.flags = REF_ISPACKED;
- if (iter->eof - p < GIT_SHA1_HEXSZ + 2 ||
+ if (iter->eof - p < the_hash_algo->hexsz + 2 ||
parse_oid_hex(p, &iter->oid, &p) ||
!isspace(*p++))
die_invalid_line(iter->snapshot->refs->path,
@@ -826,7 +826,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 < GIT_SHA1_HEXSZ + 1 ||
+ if (iter->eof - p < the_hash_algo->hexsz + 1 ||
parse_oid_hex(p, &iter->peeled, &p) ||
*p++ != '\n')
die_invalid_line(iter->snapshot->refs->path,