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

Re: [PATCH 2/5] pretty: allow formatting names as initials

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 29, 2016, 17:31 UTC
Message-ID
<xmqq37kihatp.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20160929083654.nofgkn6kwb7bavzk@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 16 quoted lines
> Initials are shorter and often unique enough in a
> per-project setting, so they can be used to give a more
> informative version of --oneline.
>
> The 'S' in the placeholder is for "short" (and 's' is
> already taken by DATE_SHORT), but obviously that's pretty
> arcane.
>
> Possibly there should be more customization of initials,
> asking for only 2-letter initials, etc.
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
> When I first tested it with "git log --format=%aS" I had to wonder "who
> the heck is ntnd?". So using only the first-and-last would match the git
> project's practice better, at least.
And there is also "isalpha() good enough?" question.

I think we have a few Chinese and Hangul as well as Cyrillic names in our history, some of them having outside-ascii first letters. One of the more prolific contributor's initial is ÆAB ;-)

Show 42 quoted lines
>  pretty.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
>
> diff --git a/pretty.c b/pretty.c
> index c532c17..de62405 100644
> --- a/pretty.c
> +++ b/pretty.c
> @@ -674,6 +674,23 @@ static int mailmap_name(const char **email, size_t *email_len,
>  	return mail_map->nr && map_user(mail_map, email, email_len, name, name_len);
>  }
>  
> +static void format_initials(struct strbuf *out, const char *name, size_t len)
> +{
> +	int initial = 1;
> +	size_t i;
> +
> +	for (i = 0; i < len; i++) {
> +		char c = name[i];
> +		if (isspace(c)) {
> +			initial = 1;
> +			continue;
> +		}
> +		if (initial && isalpha(c))
> +			strbuf_addch(out, tolower(c));
> +		initial = 0;
> +	}
> +}
> +
>  static size_t format_person_part(struct strbuf *sb, char part,
>  				 const char *msg, int len,
>  				 const struct date_mode *dmode)
> @@ -702,6 +719,10 @@ static size_t format_person_part(struct strbuf *sb, char part,
>  		strbuf_add(sb, mail, maillen);
>  		return placeholder_len;
>  	}
> +	if (part == 'S') {
> +		format_initials(sb, name, namelen);
> +		return placeholder_len;
> +	}
>  
>  	if (!s.date_begin)
>  		goto skip;
Previous: Jeff KingNext: Jeff King
Message 11 of 20 in “git log --oneline alternative with dates, times and initials”
  1. git log --oneline alternative with dates, times and initialsKyle J. McKay, Sep 29, 2016
  2. Jeff KingSep 29, 2016
  3. 1/5 pretty: allow formatting DATE_SHORTJeff King, Sep 29, 2016
  4. Jacob KellerSep 30, 2016
  5. SZEDER GáborSep 30, 2016
  6. Jacob KellerSep 30, 2016
  7. Jeff KingOct 1, 2016
  8. 3/5 graph: fix extra spaces in graph_padding_lineJeff King, Sep 29, 2016
  9. 4/5 graph: helper functions for printing commit headerJeff King, Sep 29, 2016
  10. 2/5 pretty: allow formatting names as initialsJeff King, Sep 29, 2016
  11. Junio C HamanoSep 29, 2016
  12. Jeff KingSep 29, 2016
  13. 5/5 log: add --commit-header optionJeff King, Sep 29, 2016
  14. Junio C HamanoSep 29, 2016
  15. Jeff KingSep 29, 2016
  16. Kyle J. McKaySep 29, 2016
  17. Jeff KingSep 29, 2016
  18. Junio C HamanoSep 29, 2016
  19. Jeff KingSep 29, 2016
  20. Junio C HamanoSep 29, 2016

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.