summaryrefslogtreecommitdiff
path: root/sha1-array.c
diff options
context:
space:
mode:
Diffstat (limited to 'sha1-array.c')
-rw-r--r--sha1-array.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/sha1-array.c b/sha1-array.c
index 5b75a5a35d..b2f47f98fb 100644
--- a/sha1-array.c
+++ b/sha1-array.c
@@ -41,3 +41,19 @@ void sha1_array_clear(struct sha1_array *array)
array->alloc = 0;
array->sorted = 0;
}
+
+void sha1_array_for_each_unique(struct sha1_array *array,
+ for_each_sha1_fn fn,
+ void *data)
+{
+ int i;
+
+ if (!array->sorted)
+ sha1_array_sort(array);
+
+ for (i = 0; i < array->nr; i++) {
+ if (i > 0 && !hashcmp(array->sha1[i], array->sha1[i-1]))
+ continue;
+ fn(array->sha1[i], data);
+ }
+}