aboutsummaryrefslogtreecommitdiffstats
path: root/mailmap.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-10-14 12:56:08 -0700
committerJunio C Hamano <gitster@pobox.com>2025-10-14 12:56:08 -0700
commit048625a6898f2bcc212f0d4baec1d18695b028a5 (patch)
tree8a7ea947d64d5bd9a7fe79770b5056e8485cb14c /mailmap.c
parentca5a44b15c0b47e4e2588541e735dfac7ebd888c (diff)
parent22e7bc801cd9c5e5b5c4489b631be28e506fec42 (diff)
downloadgit-048625a6898f2bcc212f0d4baec1d18695b028a5.tar.gz
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"
Diffstat (limited to 'mailmap.c')
-rw-r--r--mailmap.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/mailmap.c b/mailmap.c
index 56c72102d9..37fd158a51 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -1,5 +1,4 @@
#define USE_THE_REPOSITORY_VARIABLE
-#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "environment.h"
@@ -243,10 +242,9 @@ void clear_mailmap(struct string_list *map)
static struct string_list_item *lookup_prefix(struct string_list *map,
const char *string, size_t len)
{
- int i = string_list_find_insert_index(map, string, 1);
- if (i < 0) {
- /* exact match */
- i = -1 - i;
+ bool exact_match;
+ size_t i = string_list_find_insert_index(map, string, &exact_match);
+ if (exact_match) {
if (!string[len])
return &map->items[i];
/*
@@ -267,7 +265,7 @@ static struct string_list_item *lookup_prefix(struct string_list *map,
* overlong key would be inserted, which must come after the
* real location of the key if one exists.
*/
- while (0 <= --i && i < map->nr) {
+ while (i-- && i < map->nr) {
int cmp = strncasecmp(map->items[i].string, string, len);
if (cmp < 0)
/*