git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 03/10] mailmap: remove email copy and length limitation

From
Antoine Pelisse <apelisse@gmail.com>
Date
Jan 9, 2013, 17:35 UTC
Message-ID
<CALWbr2wp7rV7Vh0=gwmWaZE5hLHQNL+UciDsL+z-1GyhS9pTkQ@mail.gmail.com>
In-Reply-To
<1357603821-8647-4-git-send-email-gitster@pobox.com>
Show 10 quoted lines
> +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;
> +               /* does it match exactly? */
> +               if (!map->items[i].string[len])
> +                       return &map->items[i];

I'm not sure the condition above is necessary, as I don't see why an exact match would not be an exact match. We have to trust the cmp function (that mailmap sets itself) to not return 0 when the lengths are different.

Show 27 quoted lines
> +       }
> +
> +       /*
> +        * i is at the exact match to an overlong key, or
> +        * location the possibly overlong key would be inserted,
> +        * which must be after the real location of the key.
> +        */
> +       while (0 <= --i && i < map->nr) {
> +               int cmp = strncasecmp(map->items[i].string, string, len);
> +               if (cmp < 0)
> +                       /*
> +                        * "i" points at a key definitely below the prefix;
> +                        * the map does not have string[0:len] in it.
> +                        */
> +                       break;
> +               else if (!cmp && !map->items[i].string[len])
> +                       /* found it */
> +                       return &map->items[i];
> +               /*
> +                * otherwise, the string at "i" may be string[0:len]
> +                * followed by a string that sorts later than string[len:];
> +                * keep trying.
> +                */
> +       }
> +       return NULL;
> +}
> +
I've tried to think about nasty use cases but everything seems fine.
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 18 in “reroll of ap/log-mailmap”
  1. 00/10 reroll of ap/log-mailmapJunio C Hamano, Jan 8, 2013
  2. 01/10 string-list: allow case-insensitive string listJunio C Hamano, Jan 8, 2013
  3. René ScharfeJan 10, 2013
  4. 02/10 Use split_ident_line to parse author and committerJunio C Hamano, Jan 8, 2013
  5. 03/10 mailmap: remove email copy and length limitationJunio C Hamano, Jan 8, 2013
  6. Antoine PelisseJan 9, 2013
  7. Junio C HamanoJan 9, 2013
  8. Junio C HamanoJan 9, 2013
  9. 04/10 mailmap: simplify map_user() interfaceJunio C Hamano, Jan 8, 2013
  10. 05/10 mailmap: add mailmap structure to rev_info and ppJunio C Hamano, Jan 8, 2013
  11. 06/10 pretty: use mailmap to display username and emailJunio C Hamano, Jan 8, 2013
  12. 07/10 log: add --use-mailmap optionJunio C Hamano, Jan 8, 2013
  13. 08/10 test: add test for --use-mailmap optionJunio C Hamano, Jan 8, 2013
  14. 09/10 log: grep author/committer using mailmapJunio C Hamano, Jan 8, 2013
  15. 10/10 log: add log.mailmap configuration optionJunio C Hamano, Jan 8, 2013
  16. Antoine PelisseJan 8, 2013
  17. Junio C HamanoJan 8, 2013
  18. Junio C HamanoJan 8, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.