path: root/oidset.c
diff options
authorJunio C Hamano <>2020-09-25 04:55:04 (GMT)
committerJunio C Hamano <>2020-09-25 05:20:58 (GMT)
commit610e2b924020fe2d6a55e7ca6651f309b85c2d1d (patch)
tree4dda607bf854f2b293862eca090389a55812857e /oidset.c
parentf58931c8d69a9499ae7bc8bae2cefa18df418270 (diff)
blame: validate and peel the object names on the ignore list
The command reads list of object names to place on the ignore list either from the command line or from a file, but they are not checked with their object type (those read from the file are not even checked for object existence). Extend the oidset_parse_file() API and allow it to take a callback that can be used to die (e.g. when an inappropriate input is read) or modify the object name read (e.g. when a tag pointing at a commit is read, and the caller wants a commit object name), and use it in the code that handles ignore list. Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'oidset.c')
1 files changed, 8 insertions, 1 deletions
diff --git a/oidset.c b/oidset.c
index 15d4e18..2d0ab76 100644
--- a/oidset.c
+++ b/oidset.c
@@ -43,6 +43,12 @@ int oidset_size(struct oidset *set)
void oidset_parse_file(struct oidset *set, const char *path)
+ oidset_parse_file_carefully(set, path, NULL, NULL);
+void oidset_parse_file_carefully(struct oidset *set, const char *path,
+ oidset_parse_tweak_fn fn, void *cbdata)
FILE *fp;
struct strbuf sb = STRBUF_INIT;
struct object_id oid;
@@ -66,7 +72,8 @@ void oidset_parse_file(struct oidset *set, const char *path)
if (!sb.len)
- if (parse_oid_hex(sb.buf, &oid, &p) || *p != '\0')
+ if (parse_oid_hex(sb.buf, &oid, &p) || *p != '\0' ||
+ (fn && fn(&oid, cbdata)))
die("invalid object name: %s", sb.buf);
oidset_insert(set, &oid);