diff options
author | Prarit Bhargava <prarit@redhat.com> | 2019-10-29 08:09:14 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-10-30 11:49:41 +0900 |
commit | d8b8217c8a16944dc61a1553464efabc450a6680 (patch) | |
tree | abb6adff8c4f1dff6418082630369842adf00741 /pretty.c | |
parent | 45e206f0d845cfc85c39c98d0090104e72176d71 (diff) | |
download | git-d8b8217c8a16944dc61a1553464efabc450a6680.tar.gz |
pretty: add "%aL" etc. to show local-part of email addresses
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.
Existing 'e/E' (as in "%ae" and "%aE") placeholders would show the
author's address as "prarit@redhat.com", which would waste columns to show
the same domain-part for all contributors when used in a project internal
to redhat. Introduce 'l/L' placeholders that strip '@' and domain part from
the e-mail address.
Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pretty.c')
-rw-r--r-- | pretty.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -696,7 +696,7 @@ static size_t format_person_part(struct strbuf *sb, char part, mail = s.mail_begin; maillen = s.mail_end - s.mail_begin; - if (part == 'N' || part == 'E') /* mailmap lookup */ + if (part == 'N' || part == 'E' || part == 'L') /* mailmap lookup */ mailmap_name(&mail, &maillen, &name, &namelen); if (part == 'n' || part == 'N') { /* name */ strbuf_add(sb, name, namelen); @@ -706,6 +706,13 @@ static size_t format_person_part(struct strbuf *sb, char part, strbuf_add(sb, mail, maillen); return placeholder_len; } + if (part == 'l' || part == 'L') { /* local-part */ + const char *at = memchr(mail, '@', maillen); + if (at) + maillen = at - mail; + strbuf_add(sb, mail, maillen); + return placeholder_len; + } if (!s.date_begin) goto skip; |