summaryrefslogtreecommitdiffstats
path: root/oidset.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-06-14 08:50:42 +0200
committerJunio C Hamano <gitster@pobox.com>2024-06-14 19:26:34 +0200
commitf2c32a66f508586a9233dc6eac27bc4689e67dc1 (patch)
tree8a57762d12afdd00dba82baf70ad801d1be96a0c /oidset.c
parenthttp-fetch: don't crash when parsing packfile without a repo (diff)
downloadgit-f2c32a66f508586a9233dc6eac27bc4689e67dc1.tar.xz
git-f2c32a66f508586a9233dc6eac27bc4689e67dc1.zip
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>
Diffstat (limited to 'oidset.c')
-rw-r--r--oidset.c8
1 files changed, 5 insertions, 3 deletions
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;