fetch_pack(): reindent function decl and defn
[gitweb.git] / string-list.c
index decfa747fcc8b9c400433dea3e202ff154b3a034..c54b816244f69614c67c532d20719081a4b34bd4 100644 (file)
@@ -136,6 +136,26 @@ void filter_string_list(struct string_list *list, int free_util,
        list->nr = dst;
 }
 
+char *string_list_longest_prefix(const struct string_list *prefixes,
+                                const char *string)
+{
+       int i, max_len = -1;
+       char *retval = NULL;
+
+       for (i = 0; i < prefixes->nr; i++) {
+               char *prefix = prefixes->items[i].string;
+               if (!prefixcmp(string, prefix)) {
+                       int len = strlen(prefix);
+                       if (len > max_len) {
+                               retval = prefix;
+                               max_len = len;
+                       }
+               }
+       }
+
+       return retval;
+}
+
 void string_list_clear(struct string_list *list, int free_util)
 {
        if (list->items) {