mailmap: drop debugging code

There's some debugging code in mailmap.c which is only compiled if you manually tweak the source to set DEBUG_MAILMAP. When it's not set, the fallback noop uses static inline functions; we couldn't use macros here because one of the functions is variadic (and variadic macros were forbidden back then, but aren't now). As a result, this triggers a -Wunused-parameter warning. We have a few options here: 1. Leave it be. Just mark it as UNUSED, or switch to a variadic macro. 2. Assume the debugging code is useful, compile it always, and trigger it with a run-time flag (e.g., with a trace key). This is pretty easy to do, and carries a pretty small runtime cost. 3. Assume the debugging is not very useful, and just rip it out. This matches what we did with a similar case in 69c5f17f11 (attr: drop DEBUG_ATTR code, 2022-10-06). The debugging flag has been mentioned only three times on the list. Once, when it was added in 2009: https://lore.kernel.org/git/cover.1234102794.git.marius@trolltech.com/ In 2013, when somebody fixed some compilation errors in the conditional code (presumably because they used it while making other changes): https://lore.kernel.org/git/1373871253-96480-1-git-send-email-sunshine@sunshineco.com/ And finally it seemed to have been useful to somebody in 2020: https://lore.kernel.org/git/87eejswql6.fsf@evledraar.gmail.com/ So it's not totally without value. On the other hand, it's not likely to be useful to non-developers (and certainly isn't if you have to recompile). And using a debugger or adding your own inspection code is likely to be as useful. So I've just dropped the code entirely here. Note that we do still have to mark a few parameters unused in callback functions which are passed to string_list_clear_func(). Those get an extra pointer with the string being cleared, which we previously fed to the debugging code. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Mar 17, 2023 at 15:16 UTC 910d07a861d3dd1cae7ee1ae85f60184c32087e8
1 file changed +3 -39
mailmap.c
+3 -39
@@ -3,16 +3,6 @@
3 #include "mailmap.h"
4 #include "object-store.h"
5
6 -#define DEBUG_MAILMAP 0
7 -#if DEBUG_MAILMAP
8 -#define debug_mm(...) fprintf(stderr, __VA_ARGS__)
9 -#define debug_str(X) ((X) ? (X) : "(none)")
10 -#else
11 -__attribute__((format (printf, 1, 2)))
12 -static inline void debug_mm(const char *format, ...) {}
13 -static inline const char *debug_str(const char *s) { return s; }
14 -#endif
15 -
6 const char *git_mailmap_file;
7 const char *git_mailmap_blob;
8
@@ -30,23 +20,17 @@ struct mailmap_entry {
20 struct string_list namemap;
21 };
22
33 -static void free_mailmap_info(void *p, const char *s)
23 +static void free_mailmap_info(void *p, const char *s UNUSED)
24 {
25 struct mailmap_info *mi = (struct mailmap_info *)p;
36 - debug_mm("mailmap: -- complex: '%s' -> '%s' <%s>\n",
37 - s, debug_str(mi->name), debug_str(mi->email));
26 free(mi->name);
27 free(mi->email);
28 free(mi);
29 }
30
43 -static void free_mailmap_entry(void *p, const char *s)
31 +static void free_mailmap_entry(void *p, const char *s UNUSED)
32 {
33 struct mailmap_entry *me = (struct mailmap_entry *)p;
46 - debug_mm("mailmap: removing entries for <%s>, with %"PRIuMAX" sub-entries\n",
47 - s, (uintmax_t)me->namemap.nr);
48 - debug_mm("mailmap: - simple: '%s' <%s>\n",
49 - debug_str(me->name), debug_str(me->email));
34
35 free(me->name);
36 free(me->email);
@@ -93,8 +77,6 @@ static void add_mapping(struct string_list *map,
77 }
78
79 if (!old_name) {
96 - debug_mm("mailmap: adding (simple) entry for '%s'\n", old_email);
97 -
80 /* Replace current name and new email for simple entry */
81 if (new_name) {
82 free(me->name);
@@ -106,15 +88,10 @@ static void add_mapping(struct string_list *map,
88 }
89 } else {
90 struct mailmap_info *mi = xcalloc(1, sizeof(struct mailmap_info));
109 - debug_mm("mailmap: adding (complex) entry for '%s'\n", old_email);
91 mi->name = xstrdup_or_null(new_name);
92 mi->email = xstrdup_or_null(new_email);
93 string_list_insert(&me->namemap, old_name)->util = mi;
94 }
114 -
115 - debug_mm("mailmap: '%s' <%s> -> '%s' <%s>\n",
116 - debug_str(old_name), old_email,
117 - debug_str(new_name), debug_str(new_email));
95 }
96
97 static char *parse_name_and_email(char *buffer, char **name,
@@ -250,11 +227,8 @@ int read_mailmap(struct string_list *map)
227
228 void clear_mailmap(struct string_list *map)
229 {
253 - debug_mm("mailmap: clearing %"PRIuMAX" entries...\n",
254 - (uintmax_t)map->nr);
230 map->strdup_strings = 1;
231 string_list_clear_func(map, free_mailmap_entry);
257 - debug_mm("mailmap: cleared\n");
232 }
233
234 /*
@@ -315,10 +289,6 @@ int map_user(struct string_list *map,
289 struct string_list_item *item;
290 struct mailmap_entry *me;
291
318 - debug_mm("map_user: map '%.*s' <%.*s>\n",
319 - (int)*namelen, debug_str(*name),
320 - (int)*emaillen, debug_str(*email));
321 -
292 item = lookup_prefix(map, *email, *emaillen);
293 if (item) {
294 me = (struct mailmap_entry *)item->util;
@@ -336,10 +306,8 @@ int map_user(struct string_list *map,
306 }
307 if (item) {
308 struct mailmap_info *mi = (struct mailmap_info *)item->util;
339 - if (mi->name == NULL && mi->email == NULL) {
340 - debug_mm("map_user: -- (no simple mapping)\n");
309 + if (mi->name == NULL && mi->email == NULL)
310 return 0;
342 - }
311 if (mi->email) {
312 *email = mi->email;
313 *emaillen = strlen(*email);
@@ -348,11 +316,7 @@ int map_user(struct string_list *map,
316 *name = mi->name;
317 *namelen = strlen(*name);
318 }
351 - debug_mm("map_user: to '%.*s' <%.*s>\n",
352 - (int)*namelen, debug_str(*name),
353 - (int)*emaillen, debug_str(*email));
319 return 1;
320 }
356 - debug_mm("map_user: --\n");
321 return 0;
322 }