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>
Patrick Steinhardt committed
Jun 14, 2024 at 08:50 UTC
f2c32a66f508586a9233dc6eac27bc4689e67dc1
4 files changed
+11
-5
builtin/blame.c
+1
@@ -852,6 +852,7 @@ static void build_ignorelist(struct blame_scoreboard *sb,
852
oidset_clear(&sb->ignore_list);
853
else
854
oidset_parse_file_carefully(&sb->ignore_list, i->string,
855
+ the_repository->hash_algo,
856
peel_to_commit_oid, sb);
857
}
858
for_each_string_list_item(i, ignore_rev_list) {
fsck.c
+2
-1
@@ -205,7 +205,8 @@ void fsck_set_msg_types(struct fsck_options *options, const char *values)
205
if (!strcmp(buf, "skiplist")) {
206
if (equal == len)
207
die("skiplist requires a path");
208
- oidset_parse_file(&options->skiplist, buf + equal + 1);
208
+ oidset_parse_file(&options->skiplist, buf + equal + 1,
209
+ the_repository->hash_algo);
210
buf += len + 1;
211
continue;
212
}
oidset.c
+5
-3
@@ -48,12 +48,14 @@ void oidset_clear(struct oidset *set)
48
oidset_init(set, 0);
49
}
50
51
-void oidset_parse_file(struct oidset *set, const char *path)
51
+void oidset_parse_file(struct oidset *set, const char *path,
52
+ const struct git_hash_algo *algop)
53
{
53
- oidset_parse_file_carefully(set, path, NULL, NULL);
54
+ oidset_parse_file_carefully(set, path, algop, NULL, NULL);
55
}
56
57
void oidset_parse_file_carefully(struct oidset *set, const char *path,
58
+ const struct git_hash_algo *algop,
59
oidset_parse_tweak_fn fn, void *cbdata)
60
{
61
FILE *fp;
@@ -79,7 +81,7 @@ void oidset_parse_file_carefully(struct oidset *set, const char *path,
81
if (!sb.len)
82
continue;
83
82
- if (parse_oid_hex(sb.buf, &oid, &p) || *p != '\0')
84
+ if (parse_oid_hex_algop(sb.buf, &oid, &p, algop) || *p != '\0')
85
die("invalid object name: %s", sb.buf);
86
if (fn && fn(&oid, cbdata))
87
continue;
oidset.h
+3
-1
@@ -80,7 +80,8 @@ void oidset_clear(struct oidset *set);
80
* are allowed. Leading whitespace and empty or white-space only lines are
81
* ignored.
82
*/
83
-void oidset_parse_file(struct oidset *set, const char *path);
83
+void oidset_parse_file(struct oidset *set, const char *path,
84
+ const struct git_hash_algo *algop);
85
86
/*
87
* 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);
90
*/
91
typedef int (*oidset_parse_tweak_fn)(struct object_id *, void *);
92
void oidset_parse_file_carefully(struct oidset *set, const char *path,
93
+ const struct git_hash_algo *algop,
94
oidset_parse_tweak_fn fn, void *cbdata);
95
96
struct oidset_iter {