mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
Merge branch 'sj/string-list'
The "string-list" API function to find where a given string would be inserted got updated so that it can use unrealistically huge array index that would only fit in size_t but not int or ssize_t to achieve unstated goal. * sj/string-list: refs: enable sign compare warnings check string-list: change "string_list_find_insert_index" return type to "size_t" string-list: replace negative index encoding with "exact_match" parameter string-list: use bool instead of int for "exact_match"
This commit is contained in:
@@ -244,7 +244,8 @@ static void find_unique_prefixes(struct prefix_item_list *list)
|
||||
|
||||
static ssize_t find_unique(const char *string, struct prefix_item_list *list)
|
||||
{
|
||||
int index = string_list_find_insert_index(&list->sorted, string, 1);
|
||||
bool exact_match;
|
||||
size_t index = string_list_find_insert_index(&list->sorted, string, &exact_match);
|
||||
struct string_list_item *item;
|
||||
|
||||
if (list->items.nr != list->sorted.nr)
|
||||
@@ -252,8 +253,8 @@ static ssize_t find_unique(const char *string, struct prefix_item_list *list)
|
||||
" vs %"PRIuMAX")",
|
||||
(uintmax_t)list->items.nr, (uintmax_t)list->sorted.nr);
|
||||
|
||||
if (index < 0)
|
||||
item = list->sorted.items[-1 - index].util;
|
||||
if (exact_match)
|
||||
item = list->sorted.items[index].util;
|
||||
else if (index > 0 &&
|
||||
starts_with(list->sorted.items[index - 1].string, string))
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user