oidset: pass hash algorithm when parsing file

The `oidset_parse_file_carefully()` function implicitly depends on
`the_repository` when parsing object IDs. Fix this by having callers
pass in the hash algorithm to use.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Patrick Steinhardt 2024-06-14 08:50:42 +02:00 committed by Junio C Hamano
parent afa2c6ddc8
commit f2c32a66f5
4 changed files with 11 additions and 5 deletions

View File

@ -852,6 +852,7 @@ static void build_ignorelist(struct blame_scoreboard *sb,
oidset_clear(&sb->ignore_list); oidset_clear(&sb->ignore_list);
else else
oidset_parse_file_carefully(&sb->ignore_list, i->string, oidset_parse_file_carefully(&sb->ignore_list, i->string,
the_repository->hash_algo,
peel_to_commit_oid, sb); peel_to_commit_oid, sb);
} }
for_each_string_list_item(i, ignore_rev_list) { for_each_string_list_item(i, ignore_rev_list) {

3
fsck.c
View File

@ -205,7 +205,8 @@ void fsck_set_msg_types(struct fsck_options *options, const char *values)
if (!strcmp(buf, "skiplist")) { if (!strcmp(buf, "skiplist")) {
if (equal == len) if (equal == len)
die("skiplist requires a path"); die("skiplist requires a path");
oidset_parse_file(&options->skiplist, buf + equal + 1); oidset_parse_file(&options->skiplist, buf + equal + 1,
the_repository->hash_algo);
buf += len + 1; buf += len + 1;
continue; continue;
} }

View File

@ -48,12 +48,14 @@ void oidset_clear(struct oidset *set)
oidset_init(set, 0); oidset_init(set, 0);
} }


void oidset_parse_file(struct oidset *set, const char *path) void oidset_parse_file(struct oidset *set, const char *path,
const struct git_hash_algo *algop)
{ {
oidset_parse_file_carefully(set, path, NULL, NULL); oidset_parse_file_carefully(set, path, algop, NULL, NULL);
} }


void oidset_parse_file_carefully(struct oidset *set, const char *path, void oidset_parse_file_carefully(struct oidset *set, const char *path,
const struct git_hash_algo *algop,
oidset_parse_tweak_fn fn, void *cbdata) oidset_parse_tweak_fn fn, void *cbdata)
{ {
FILE *fp; FILE *fp;
@ -79,7 +81,7 @@ void oidset_parse_file_carefully(struct oidset *set, const char *path,
if (!sb.len) if (!sb.len)
continue; continue;


if (parse_oid_hex(sb.buf, &oid, &p) || *p != '\0') if (parse_oid_hex_algop(sb.buf, &oid, &p, algop) || *p != '\0')
die("invalid object name: %s", sb.buf); die("invalid object name: %s", sb.buf);
if (fn && fn(&oid, cbdata)) if (fn && fn(&oid, cbdata))
continue; continue;

View File

@ -80,7 +80,8 @@ void oidset_clear(struct oidset *set);
* are allowed. Leading whitespace and empty or white-space only lines are * are allowed. Leading whitespace and empty or white-space only lines are
* ignored. * ignored.
*/ */
void oidset_parse_file(struct oidset *set, const char *path); void oidset_parse_file(struct oidset *set, const char *path,
const struct git_hash_algo *algop);


/* /*
* Similar to the above, but with a callback which can (1) return non-zero to * Similar to the above, but with a callback which can (1) return non-zero to
@ -89,6 +90,7 @@ void oidset_parse_file(struct oidset *set, const char *path);
*/ */
typedef int (*oidset_parse_tweak_fn)(struct object_id *, void *); typedef int (*oidset_parse_tweak_fn)(struct object_id *, void *);
void oidset_parse_file_carefully(struct oidset *set, const char *path, void oidset_parse_file_carefully(struct oidset *set, const char *path,
const struct git_hash_algo *algop,
oidset_parse_tweak_fn fn, void *cbdata); oidset_parse_tweak_fn fn, void *cbdata);


struct oidset_iter { struct oidset_iter {