From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: "brian m. carlson" <sandals@crustytoothpaste.net>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>,
Phillip Wood <phillip.wood123@gmail.com>
Subject: Re: [PATCH v2 1/5] mailmap: add a function to inspect the number of entries
Date: Mon, 04 Jan 2021 16:14:20 +0100 [thread overview]
Message-ID: <87im8cvinn.fsf@evledraar.gmail.com> (raw)
In-Reply-To: <20210103211849.2691287-2-sandals@crustytoothpaste.net>
On Sun, Jan 03 2021, brian m. carlson wrote:
> We're soon going to change the type of our mailmap into an opaque struct
> so we can add features and improve performance. When we do so, it won't
> be possible for users to inspect its internals to determine how many
> items are present, so let's introduce a function that lets users inquire
> how many objects are in the mailmap and use it where we want this
> information.
>
> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
> ---
> mailmap.c | 5 +++++
> mailmap.h | 1 +
> pretty.c | 2 +-
> 3 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/mailmap.c b/mailmap.c
> index 962fd86d6d..c9a538f4e2 100644
> --- a/mailmap.c
> +++ b/mailmap.c
> @@ -361,3 +361,8 @@ int map_user(struct string_list *map,
> debug_mm("map_user: --\n");
> return 0;
> }
> +
> +int mailmap_entries(struct string_list *map)
We're returning ->nr here from string_list, whose "nr" is unsigned
int. Wouldn't it make more sense to do the same here?...
> +{
> + return map->nr;
> +}
> diff --git a/mailmap.h b/mailmap.h
> index d0e65646cb..ff57b05a15 100644
> --- a/mailmap.h
> +++ b/mailmap.h
> @@ -5,6 +5,7 @@ struct string_list;
>
> int read_mailmap(struct string_list *map, char **repo_abbrev);
> void clear_mailmap(struct string_list *map);
> +int mailmap_entries(struct string_list *map);
>
> int map_user(struct string_list *map,
> const char **email, size_t *emaillen, const char **name, size_t *namelen);
> diff --git a/pretty.c b/pretty.c
> index 7a7708a0ea..43a0039870 100644
> --- a/pretty.c
> +++ b/pretty.c
> @@ -681,7 +681,7 @@ static int mailmap_name(const char **email, size_t *email_len,
> mail_map = xcalloc(1, sizeof(*mail_map));
> read_mailmap(mail_map, NULL);
> }
> - return mail_map->nr && map_user(mail_map, email, email_len, name, name_len);
> + return mailmap_entries(mail_map) && map_user(mail_map, email, email_len, name, name_len);
...and isn't this introducing a bug where the number of entries is
beyond "signed int" but not "unsigned int" by overflowing?
Bikeshedding: For both hashmap and strmap we have a
{hashmap,strmap}_get_size() function. I think a "static inline unsigned
int mailmap_get_size()" here would be more consistent & obvious.
> }
>
> static size_t format_person_part(struct strbuf *sb, char part,
next prev parent reply other threads:[~2021-01-04 15:19 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-03 21:18 [PATCH v2 0/5] Hashed mailmap brian m. carlson
2021-01-03 21:18 ` [PATCH v2 1/5] mailmap: add a function to inspect the number of entries brian m. carlson
2021-01-04 15:14 ` Ævar Arnfjörð Bjarmason [this message]
2021-01-04 17:04 ` René Scharfe
2021-01-03 21:18 ` [PATCH v2 2/5] mailmap: switch to opaque struct brian m. carlson
2021-01-04 15:17 ` Ævar Arnfjörð Bjarmason
2021-01-03 21:18 ` [PATCH v2 3/5] t4203: add failing test for case-sensitive local-parts and names brian m. carlson
2021-01-03 21:18 ` [PATCH v2 4/5] mailmap: use case-sensitive comparisons for " brian m. carlson
2021-01-04 16:10 ` Ævar Arnfjörð Bjarmason
2021-01-06 0:46 ` Junio C Hamano
2021-01-12 14:08 ` Ævar Arnfjörð Bjarmason
2021-01-03 21:18 ` [PATCH v2 5/5] mailmap: support hashed entries in mailmaps brian m. carlson
2021-01-05 14:21 ` Ævar Arnfjörð Bjarmason
2021-01-06 0:24 ` brian m. carlson
2021-01-10 19:24 ` Ævar Arnfjörð Bjarmason
2021-01-10 21:26 ` brian m. carlson
2021-01-05 20:05 ` Junio C Hamano
2021-01-06 0:28 ` brian m. carlson
2021-01-06 1:50 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87im8cvinn.fsf@evledraar.gmail.com \
--to=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=phillip.wood123@gmail.com \
--cc=sandals@crustytoothpaste.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).