]> git.ipfire.org Git - thirdparty/git.git/commitdiff
oidset: pass hash algorithm when parsing file
authorPatrick Steinhardt <ps@pks.im>
Fri, 14 Jun 2024 06:50:42 +0000 (08:50 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 14 Jun 2024 17:26:34 +0000 (10:26 -0700)
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>
builtin/blame.c
fsck.c
oidset.c
oidset.h

index de89fff3f80bc35a031b76a36327050ef37cf7dc..18f1a3cea004f71ab211ceadfcfabdae7616b552 100644 (file)
@@ -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 432996cbb6c5f19c4efd1e33eb2c6774f3dce73e..304f4a17ecc1b4b77e3f70b955f47954e2339c2a 100644 (file)
--- 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;
                }
index 91d13859106a1bc56632aeedd4030a007608a359..8d36aef8dca4fca8aa979692a536687a21f2b90d 100644 (file)
--- 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;
index 262f4256d6ac5ad39e1cef4a39e36716e817d651..0106b6f2787f0e4a5feff560554f5bd25748313b 100644 (file)
--- 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 {