diff options
Diffstat (limited to 'third_party/git/oidset.c')
-rw-r--r-- | third_party/git/oidset.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/third_party/git/oidset.c b/third_party/git/oidset.c index f63ce818f677..2d0ab76fb569 100644 --- a/third_party/git/oidset.c +++ b/third_party/git/oidset.c @@ -36,8 +36,19 @@ void oidset_clear(struct oidset *set) oidset_init(set, 0); } +int oidset_size(struct oidset *set) +{ + return kh_size(&set->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; @@ -61,7 +72,8 @@ void oidset_parse_file(struct oidset *set, const char *path) if (!sb.len) continue; - 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); } |