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

[PATCH v2 1/5] mailmap: add a function to inspect the number of entries

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Jan 3, 2021, 21:18 UTC
Message-ID
<20210103211849.2691287-2-sandals@crustytoothpaste.net>
In-Reply-To
<20210103211849.2691287-1-sandals@crustytoothpaste.net>

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)
+{
+	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);
 }
 
 static size_t format_person_part(struct strbuf *sb, char part,
Previous: brian m. carlsonNext: Ævar Arnfjörð Bjarmason
Message 2 of 19 in “Hashed mailmap”
  1. 0/5 Hashed mailmapbrian m. carlson, Jan 3, 2021
  2. 1/5 mailmap: add a function to inspect the number of entriesbrian m. carlson, Jan 3, 2021
  3. Ævar Arnfjörð BjarmasonJan 4, 2021
  4. René ScharfeJan 4, 2021
  5. 2/5 mailmap: switch to opaque structbrian m. carlson, Jan 3, 2021
  6. Ævar Arnfjörð BjarmasonJan 4, 2021
  7. 3/5 t4203: add failing test for case-sensitive local-parts and namesbrian m. carlson, Jan 3, 2021
  8. 4/5 mailmap: use case-sensitive comparisons for local-parts and namesbrian m. carlson, Jan 3, 2021
  9. Ævar Arnfjörð BjarmasonJan 4, 2021
  10. Junio C HamanoJan 6, 2021
  11. Ævar Arnfjörð BjarmasonJan 12, 2021
  12. 5/5 mailmap: support hashed entries in mailmapsbrian m. carlson, Jan 3, 2021
  13. Ævar Arnfjörð BjarmasonJan 5, 2021
  14. brian m. carlsonJan 6, 2021
  15. Ævar Arnfjörð BjarmasonJan 10, 2021
  16. brian m. carlsonJan 10, 2021
  17. Junio C HamanoJan 5, 2021
  18. brian m. carlsonJan 6, 2021
  19. Junio C HamanoJan 6, 2021

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.