Skip to content

Commit f2c32a6

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent afa2c6d commit f2c32a6

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

builtin/blame.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,7 @@ static void build_ignorelist(struct blame_scoreboard *sb,
852852
oidset_clear(&sb->ignore_list);
853853
else
854854
oidset_parse_file_carefully(&sb->ignore_list, i->string,
855+
the_repository->hash_algo,
855856
peel_to_commit_oid, sb);
856857
}
857858
for_each_string_list_item(i, ignore_rev_list) {

fsck.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ void fsck_set_msg_types(struct fsck_options *options, const char *values)
205205
if (!strcmp(buf, "skiplist")) {
206206
if (equal == len)
207207
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);
209210
buf += len + 1;
210211
continue;
211212
}

oidset.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@ void oidset_clear(struct oidset *set)
4848
oidset_init(set, 0);
4949
}
5050

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)
5253
{
53-
oidset_parse_file_carefully(set, path, NULL, NULL);
54+
oidset_parse_file_carefully(set, path, algop, NULL, NULL);
5455
}
5556

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

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

oidset.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ void oidset_clear(struct oidset *set);
8080
* are allowed. Leading whitespace and empty or white-space only lines are
8181
* ignored.
8282
*/
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);
8485

8586
/*
8687
* 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);
8990
*/
9091
typedef int (*oidset_parse_tweak_fn)(struct object_id *, void *);
9192
void oidset_parse_file_carefully(struct oidset *set, const char *path,
93+
const struct git_hash_algo *algop,
9294
oidset_parse_tweak_fn fn, void *cbdata);
9395

9496
struct oidset_iter {

0 commit comments

Comments
 (0)