ref-filter: move ref_cbdata definition into ref-filter.c
[gitweb.git] / sha1-array.c
index 21188deb7a4c44b279ae9ca2b67a0a785f2950ef..c1cc25cd95da66aec1c695f4bba9680f5cb834f6 100644 (file)
@@ -42,7 +42,7 @@ void sha1_array_clear(struct sha1_array *array)
        array->sorted = 0;
 }
 
-void sha1_array_for_each_unique(struct sha1_array *array,
+int sha1_array_for_each_unique(struct sha1_array *array,
                                for_each_sha1_fn fn,
                                void *data)
 {
@@ -52,8 +52,12 @@ void sha1_array_for_each_unique(struct sha1_array *array,
                sha1_array_sort(array);
 
        for (i = 0; i < array->nr; i++) {
+               int ret;
                if (i > 0 && !hashcmp(array->sha1[i], array->sha1[i-1]))
                        continue;
-               fn(array->sha1[i], data);
+               ret = fn(array->sha1[i], data);
+               if (ret)
+                       return ret;
        }
+       return 0;
 }