packaging: Add contrib installation
[platform/upstream/git.git] / oidset.c
index f63ce81..5aac633 100644 (file)
--- a/oidset.c
+++ b/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;
@@ -63,6 +74,8 @@ void oidset_parse_file(struct oidset *set, const char *path)
 
                if (parse_oid_hex(sb.buf, &oid, &p) || *p != '\0')
                        die("invalid object name: %s", sb.buf);
+               if (fn && fn(&oid, cbdata))
+                       continue;
                oidset_insert(set, &oid);
        }
        if (ferror(fp))