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

Re: [PATCH] pretty: Add "%aU"|"%au" option to output author's username

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 22, 2019, 23:46 UTC
Message-ID
<xmqqy2xcjqc8.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20191022232847.5212-1-prarit@redhat.com>
Prarit Bhargava <prarit@redhat.com> writes:
> Subject: Re: [PATCH] pretty: Add "%aU"|"%au" option to output author's username

Downcase "Add" (see "git shortlog --no-merges -100 master" and mimick the project convention).

> Add a "%aU"|"%au" option that outputs the author's email username.

Even though I personally do not see the use for it, I agree it would make sense to have an option to show the local part only where the e-mail address is shown.

I do not know if u/U is a good mnemonic; it hints too strongly that it may come from GIT_{AUTHOR/COMMITTER}_NAME but that is not what you are doing---isn't there a letter that better conveys that this is about RFC 2822 local-part (cf. page 16 ieft.org/rfc/rfc2822.txt)?

Show 14 quoted lines
> diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
> index b87e2e83e6d0..479a15a8ab12 100644
> --- a/Documentation/pretty-formats.txt
> +++ b/Documentation/pretty-formats.txt
> @@ -163,6 +163,9 @@ The placeholders are:
>  '%ae':: author email
>  '%aE':: author email (respecting .mailmap, see linkgit:git-shortlog[1]
>  	or linkgit:git-blame[1])
> +'%au':: author username
> +'%aU':: author username (respecting .mailmap, see linkgit:git-shortlog[1]
> +	or linkgit:git-blame[1])
>  '%ad':: author date (format respects --date= option)
>  '%aD':: author date, RFC2822 style
>  '%ar':: author date, relative
Show 13 quoted lines
> diff --git a/pretty.c b/pretty.c
> index b32f0369531c..2a5b93022050 100644
> --- a/pretty.c
> +++ b/pretty.c
> @@ -706,6 +706,11 @@ static size_t format_person_part(struct strbuf *sb, char part,
>  		strbuf_add(sb, mail, maillen);
>  		return placeholder_len;
>  	}
> +	if (part == 'u' || part == 'U') {	/* username */
> +		maillen = strstr(s.mail_begin, "@") - s.mail_begin;
> +		strbuf_add(sb, mail, maillen);
> +		return placeholder_len;
> +	}

I think users get %eu and %eU for free with this change, which should be documented.

Previous: Prarit BhargavaNext: Prarit Bhargava
Message 2 of 9 in “pretty: Add "%aU"|"%au" option to output author's username”
  1. pretty: Add "%aU"|"%au" option to output author's usernamePrarit Bhargava, Oct 22, 2019
  2. Junio C HamanoOct 22, 2019
  3. Prarit BhargavaOct 23, 2019
  4. brian m. carlsonOct 22, 2019
  5. Prarit BhargavaOct 23, 2019
  6. Junio C HamanoOct 24, 2019
  7. Prarit BhargavaOct 24, 2019
  8. Jeff KingOct 23, 2019
  9. Prarit BhargavaOct 23, 2019

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.