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@xxxxxx> --- builtin/blame.c | 1 + fsck.c | 3 ++- oidset.c | 8 +++++--- oidset.h | 4 +++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/builtin/blame.c b/builtin/blame.c index de89fff3f8..18f1a3cea0 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -852,6 +852,7 @@ static void build_ignorelist(struct blame_scoreboard *sb, oidset_clear(&sb->ignore_list); else oidset_parse_file_carefully(&sb->ignore_list, i->string, + the_repository->hash_algo, peel_to_commit_oid, sb); } for_each_string_list_item(i, ignore_rev_list) { diff --git a/fsck.c b/fsck.c index 432996cbb6..304f4a17ec 100644 --- a/fsck.c +++ b/fsck.c @@ -205,7 +205,8 @@ void fsck_set_msg_types(struct fsck_options *options, const char *values) if (!strcmp(buf, "skiplist")) { if (equal == len) 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; continue; } diff --git a/oidset.c b/oidset.c index 91d1385910..8d36aef8dc 100644 --- a/oidset.c +++ b/oidset.c @@ -48,12 +48,14 @@ void oidset_clear(struct oidset *set) 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, + const struct git_hash_algo *algop, oidset_parse_tweak_fn fn, void *cbdata) { FILE *fp; @@ -79,7 +81,7 @@ void oidset_parse_file_carefully(struct oidset *set, const char *path, if (!sb.len) 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); if (fn && fn(&oid, cbdata)) continue; diff --git a/oidset.h b/oidset.h index 262f4256d6..0106b6f278 100644 --- a/oidset.h +++ b/oidset.h @@ -80,7 +80,8 @@ void oidset_clear(struct oidset *set); * are allowed. Leading whitespace and empty or white-space only lines are * 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 @@ -89,6 +90,7 @@ void oidset_parse_file(struct oidset *set, const char *path); */ typedef int (*oidset_parse_tweak_fn)(struct object_id *, void *); void oidset_parse_file_carefully(struct oidset *set, const char *path, + const struct git_hash_algo *algop, oidset_parse_tweak_fn fn, void *cbdata); struct oidset_iter { -- 2.45.2.436.gcd77e87115.dirty
Attachment:
signature.asc
Description: PGP signature