summaryrefslogtreecommitdiff
path: root/pretty.c
diff options
context:
space:
mode:
authorPrarit Bhargava <prarit@redhat.com>2019-10-29 08:09:14 -0400
committerJunio C Hamano <gitster@pobox.com>2019-10-30 11:49:41 +0900
commitd8b8217c8a16944dc61a1553464efabc450a6680 (patch)
treeabb6adff8c4f1dff6418082630369842adf00741 /pretty.c
parent45e206f0d845cfc85c39c98d0090104e72176d71 (diff)
downloadgit-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.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/pretty.c b/pretty.c
index b32f036953..93eb6e8370 100644
--- a/pretty.c
+++ b/pretty.c
@@ -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;