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
Junio C Hamano <gitster@pobox.com>
Date
Jan 9, 2013, 17:56 UTC
Message-ID
<7vbocy6y0n.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7vfw2a6yh5.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 20 quoted lines
> Antoine Pelisse <apelisse@gmail.com> writes:
>
>>> +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.
>
> You have a overlong string "ABCDEFG", but you only want to look for
> "ABCDEF", i.e. len=6.  The string_list happens to have an existing
> string "ABCDEFG".  The insert-index function will report an exact
> match, but that does not mean you found what you are looking for. 

To put it another way, we can further clarify the situation by rewording the comment "Does it match exactly?", perhaps like this

	if (i < 0) {
                /* exact match */
                i = -1 - i;
                if (!string[len])
                        return &map->items[i];
                /*
                 * It matched exactly even to the cruft at the end
                 * of the string, so it is not really a match.
                 */
	}
Previous: Junio C HamanoNext: Junio C Hamano
Message 8 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.