msvc: do not re-declare the timespec struct
[gitweb.git] / sha1-array.c
index 265941fbf40d4a6c64bb1e77b2aef7a5950493a7..d922e94e3fc58488402ac0095075bf5ef0e4d17b 100644 (file)
@@ -69,7 +69,7 @@ int oid_array_for_each_unique(struct oid_array *array,
 
        for (i = 0; i < array->nr; i++) {
                int ret;
-               if (i > 0 && !oidcmp(array->oid + i, array->oid + i - 1))
+               if (i > 0 && oideq(array->oid + i, array->oid + i - 1))
                        continue;
                ret = fn(array->oid + i, data);
                if (ret)
@@ -77,3 +77,20 @@ int oid_array_for_each_unique(struct oid_array *array,
        }
        return 0;
 }
+
+void oid_array_filter(struct oid_array *array,
+                     for_each_oid_fn want,
+                     void *cb_data)
+{
+       unsigned nr = array->nr, src, dst;
+       struct object_id *oids = array->oid;
+
+       for (src = dst = 0; src < nr; src++) {
+               if (want(&oids[src], cb_data)) {
+                       if (src != dst)
+                               oidcpy(&oids[dst], &oids[src]);
+                       dst++;
+               }
+       }
+       array->nr = dst;
+}