summaryrefslogtreecommitdiff
path: root/sha1-array.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-05-30 14:04:11 +0900
committerJunio C Hamano <gitster@pobox.com>2018-05-30 14:04:11 +0900
commitab48bc0aeadd7f6b661bc125a913e1c7d145cd5e (patch)
tree98bbbcf8dd2e210de83c71b2aecc508e9e7ba395 /sha1-array.c
parent54db5c0e1edf0d92bd474f515fab349b98c18a24 (diff)
parent5cc044e02571e93048160d94e64fe6d8dd96597e (diff)
Merge branch 'ab/get-short-oid'
When a short hexadecimal string is used to name an object but there are multiple objects that share the string as the prefix of their names, the code lists these ambiguous candidates in a help message. These object names are now sorted according to their types for easier eyeballing. * ab/get-short-oid: get_short_oid: sort ambiguous objects by type, then SHA-1 sha1-name.c: move around the collect_ambiguous() function git-p4: change "commitish" typo to "committish" sha1-array.h: align function arguments sha1-name.c: remove stray newline
Diffstat (limited to 'sha1-array.c')
-rw-r--r--sha1-array.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/sha1-array.c b/sha1-array.c
index 838b3bf847..265941fbf4 100644
--- a/sha1-array.c
+++ b/sha1-array.c
@@ -41,9 +41,26 @@ void oid_array_clear(struct oid_array *array)
array->sorted = 0;
}
+
+int oid_array_for_each(struct oid_array *array,
+ for_each_oid_fn fn,
+ void *data)
+{
+ int i;
+
+ /* No oid_array_sort() here! See the api-oid-array.txt docs! */
+
+ for (i = 0; i < array->nr; i++) {
+ int ret = fn(array->oid + i, data);
+ if (ret)
+ return ret;
+ }
+ return 0;
+}
+
int oid_array_for_each_unique(struct oid_array *array,
- for_each_oid_fn fn,
- void *data)
+ for_each_oid_fn fn,
+ void *data)
{
int i;