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

Re: [PATCH v3 1/1] cat-file: add mailmap subcommand to --batch-command

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 31, 2026, 19:21 UTC
Message-ID
<xmqqo6k3ztxr.fsf@gitster.g>
In-Reply-To
<20260331121111.9614-2-siddharthasthana31@gmail.com>
Siddharth Asthana <siddharthasthana31@gmail.com> writes:
Show 11 quoted lines
> git-cat-file(1)'s --batch-command works with the --use-mailmap option,
> but this option needs to be set when the process is created. This means
> we cannot change this option mid-operation.
>
> At GitLab, Gitaly keeps interacting with a long-lived git-cat-file
> process and it would be useful if --batch-command supported toggling
> mailmap dynamically on an existing process.
>
> Add a `mailmap` subcommand to --batch-command that takes a boolean
> argument. The command now uses `git_parse_maybe_bool()` and supports all
> standard Git boolean values. Mailmap data is loaded lazily and kept in

I do not think you want to say "now uses `git_parse_maybe_bool()`". Nobody is interested in the difference relative to what you did in the previous iteration.

    ... that takes a boolean argument (usual ways you can specify a
    boolean value like 'yes', 'true', etc., are supported).
Show 7 quoted lines
> +static void load_mailmap(void)
> +{
> +	if (mailmap.strdup_strings)
> +		return;
> +
> +	read_mailmap(the_repository, &mailmap);
> +}

This, especially the early return condition, may deserve a bit of in-code comment, as "a used string_list has the .strdup_strings bit set" is not a generally applicable rule.

    /*
     * The mailmap is initialized with .strdup_strings set to 0,
     * but read_mailmap() sets the bit to 1 (this is true even when
     * not a single mailmap entry is read), so it can be used for
     * lazy loading.
     */
or something, perhaps?
Show 10 quoted lines
> @@ -692,6 +700,21 @@ static void parse_cmd_info(struct batch_options *opt,
>  	batch_one_object(line, output, opt, data);
>  }
>  
> +static void parse_cmd_mailmap(struct batch_options *opt UNUSED,
> +			      const char *line,
> +			      struct strbuf *output UNUSED,
> +			      struct expand_data *data UNUSED)
> +{
> +	int value = git_parse_maybe_bool(line);

As "line" is never NULL, one standard way to spell a boolean True is not available to the callers, namely, "mailmap<EOL>" (like how a configuration file entry "[core] bare" means "[core] bare = true"), but that is probably OK. "mailmap<SP><EOL>" may be interpreted as feeding an empty string as an argument, which is "false" to the git_parse_maybe_bool() function. That might be surprising.

Nothing actionable in the above comment (other than perhaps as a hint for documentation update).

Show 7 quoted lines
> +	if (value < 0)
> +		die(_("mailmap: invalid boolean '%s'"), line);
> +
> +	if (value > 0)
> +		load_mailmap();
> +	use_mailmap = value;
> +}

Hmph, why not use use_mailmap from the beginning of the function without introducing the local variable "value"? Nothing in load_mailmap() pays attention to the current value of use_mailmap so I do not see much point in preserving the current status until the last minute.

Thanks.
Previous: Siddharth AsthanaNext: Junio C Hamano
Message 20 of 28 in “cat-file: add use-mailmap/no-use-mailmap to --batch-command”
  1. 1/1 cat-file: add use-mailmap/no-use-mailmap to --batch-commandSiddharth Asthana, Mar 28, 2026
  2. Junio C HamanoMar 29, 2026
  3. Siddharth AsthanaMar 29, 2026
  4. Junio C HamanoMar 29, 2026
  5. 0/1 cat-file: add mailmap subcommand to --batch-commandSiddharth Asthana, Mar 29, 2026
  6. 1/1 cat-file: add mailmap subcommand to --batch-commandSiddharth Asthana, Mar 29, 2026
  7. Junio C HamanoMar 30, 2026
  8. Siddharth AsthanaMar 31, 2026
  9. Junio C HamanoMar 31, 2026
  10. Karthik NayakMar 30, 2026
  11. Siddharth AsthanaMar 31, 2026
  12. Patrick SteinhardtMar 30, 2026
  13. Junio C HamanoMar 30, 2026
  14. Siddharth AsthanaMar 31, 2026
  15. Jean-Noël AVILAMar 31, 2026
  16. Junio C HamanoMar 31, 2026
  17. Jean-Noël AvilaApr 1, 2026
  18. 0/1 cat-file: add mailmap subcommand to --batch-commandSiddharth Asthana, Mar 31, 2026
  19. 1/1 cat-file: add mailmap subcommand to --batch-commandSiddharth Asthana, Mar 31, 2026
  20. Junio C HamanoMar 31, 2026
  21. Junio C HamanoApr 10, 2026
  22. 0/1 cat-file: add mailmap subcommand to --batch-commandSiddharth Asthana, Apr 15, 2026
  23. 1/1 cat-file: add mailmap subcommand to --batch-commandSiddharth Asthana, Apr 15, 2026
  24. Junio C HamanoApr 15, 2026
  25. Siddharth AsthanaApr 16, 2026
  26. 0/1 cat-file: add mailmap subcommand to --batch-commandSiddharth Asthana, Apr 16, 2026
  27. 1/1 cat-file: add mailmap subcommand to --batch-commandSiddharth Asthana, Apr 16, 2026
  28. Junio C HamanoMay 20, 2026

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.