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
Prarit Bhargava <prarit@redhat.com>
Date
Oct 23, 2019, 15:08 UTC
Message-ID
<83b6ad72-9077-a4ce-09b7-84ce6aabf84f@redhat.com>
In-Reply-To
<20191022234822.f4ixqcpfytimiscn@camp.crustytoothpaste.net>
On 10/22/19 7:48 PM, brian m. carlson wrote:
Show 30 quoted lines
> On 2019-10-22 at 23:28:47, Prarit Bhargava wrote:
>> In many projects the number of contributors is low enough that users know
>> each other and the full email address doesn't need to be displayed.
>> Displaying only the author's username saves a lot of columns on the screen.
>> For example displaying "prarit" instead of "prarit@redhat.com" saves 11
>> columns.
>>
>> Add a "%aU"|"%au" option that outputs the author's email username.
> 
> I have no position on whether or not this is a useful change.  I don't
> think I'll end up using it, but I can imagine cases where it is useful,
> such as certain corporate environments.  It would be interesting to see
> what others think.
> 
>> 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])
> 
> I think we need to actually document what "username" means here.  I
> expect you'll have people think that this magically means their
> $HOSTING_PLATFORM username, which it is not.
> 
Based on Junio's input, I'm going to change the option to "al" and "aL" where L
means "local-part" as defined by the rfc2822.txt specification, and include a
comment that says "(the portion of the email address preceding the '@' symbol)".
 Admittedly that doesn't convey the meaning of the mailbox concept of the email
address it does tell a user what is going to be output.
Show 18 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;
>> +	}
> 
> This branch doesn't appear to do anything different for the mailmap and
> non-mailmap cases.  Perhaps adding an additional test that demonstrates
> the difference would be a good idea.
> 
Thanks for the suggestion.  I'll look into it for v2.
P.
Previous: brian m. carlsonNext: Junio C Hamano
Message 5 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.