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

Re: [PATCH 4/5] pretty: Add name_and_address_only parameter

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 25, 2023, 02:23 UTC
Message-ID
<xmqqedrjfj2x.fsf@gitster.g>
In-Reply-To
<20230119223858.29262-5-zev@bewilderbeest.net>
Zev Weiss <zev@bewilderbeest.net> writes:
Show 5 quoted lines
> This is meant to be used with pp_user_info() when using it to format
> email recipients generated by --to-cmd/--cc-cmd.  When set it omits
> the leading 'From: ', trailing linefeed, and the date suffix, and
> additionally will return the input string unmodified if
> split_ident_line() can't parse it (e.g. for a bare email address).

It is somewhat disturbing to see that this only takes effect when cmit_fmt_is_mail(pp->fmt) and completely ignored otherwise. Seeing pp->fmt and pp->name_and_address_only sitting next to each other, it looks like a layering error.

I wonder if you instead want a new value for pp->fmt that cmit_fmt_is_mail() considers an e-mail format but is different from what we used for usual e-mail format?

Show 14 quoted lines
> diff --git a/pretty.c b/pretty.c
> index 1e1e21878c83..e6798fadc107 100644
> --- a/pretty.c
> +++ b/pretty.c
> @@ -509,8 +509,11 @@ void pp_user_info(struct pretty_print_context *pp,
>  		return;
>  
>  	line_end = strchrnul(line, '\n');
> -	if (split_ident_line(&ident, line, line_end - line))
> +	if (split_ident_line(&ident, line, line_end - line)) {
> +		if (pp->name_and_address_only)
> +			strbuf_addstr(sb, line);
>  		return;
> +	}

This error handling is also disturbing. What makes it correct to parrot the original input that does not parse correctly as an ident line to the output, only when name_and_address_only bit is on? It does not make any sense to do so when cmit_fmt_is_mail(pp->fmt) is false, especially.

Previous: Zev WeissNext: Calvin Wan
Message 8 of 14 in “format-patch: Add --{to,cc}-cmd support”
  1. 0/5 format-patch: Add --{to,cc}-cmd supportZev Weiss, Jan 19, 2023
  2. 3/5 log: Push to/cc handling down into show_log()Zev Weiss, Jan 19, 2023
  3. Junio C HamanoJan 20, 2023
  4. Calvin WanFeb 1, 2023
  5. 2/5 log: Refactor duplicated code to headerize recipient listsZev Weiss, Jan 19, 2023
  6. Junio C HamanoJan 25, 2023
  7. 4/5 pretty: Add name_and_address_only parameterZev Weiss, Jan 19, 2023
  8. Junio C HamanoJan 25, 2023
  9. Calvin WanFeb 1, 2023
  10. 1/5 t4014: Add test checking cover-letter To headerZev Weiss, Jan 19, 2023
  11. Calvin WanFeb 1, 2023
  12. 5/5 format-patch: Add support for --{to,cc}-cmd flagsZev Weiss, Jan 19, 2023
  13. Calvin WanFeb 1, 2023
  14. Calvin WanFeb 1, 2023

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.