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

Re: [PATCH v2 1/8] shortlog: change "author" variables to "ident"

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 27, 2020, 19:18 UTC
Message-ID
<xmqqpn67ni3i.fsf@gitster.c.googlers.com>
In-Reply-To
<20200927083952.GA2465761@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
> We already match "committer", and we're about to start
> matching more things. Let's use a more neutral variable to
> avoid confusion.
Looks good at least when seen alone.

It is curious how we are going to handle less structured nature of trailers. The author and committer header fields are required to be in good shape, but it is perfectly fine for *-by lines to be just human-readable strings (e.g. without <address@looking.tokens>).

We'll see.
Thanks.
Show 106 quoted lines
> Signed-off-by: Jeff King <peff@peff.net>
> ---
>  builtin/shortlog.c | 36 ++++++++++++++++++------------------
>  1 file changed, 18 insertions(+), 18 deletions(-)
>
> diff --git a/builtin/shortlog.c b/builtin/shortlog.c
> index c856c58bb5..edcf2e0d54 100644
> --- a/builtin/shortlog.c
> +++ b/builtin/shortlog.c
> @@ -49,12 +49,12 @@ static int compare_by_list(const void *a1, const void *a2)
>  }
>  
>  static void insert_one_record(struct shortlog *log,
> -			      const char *author,
> +			      const char *ident,
>  			      const char *oneline)
>  {
>  	struct string_list_item *item;
>  
> -	item = string_list_insert(&log->list, author);
> +	item = string_list_insert(&log->list, ident);
>  
>  	if (log->summary)
>  		item->util = (void *)(UTIL_TO_INT(item) + 1);
> @@ -97,8 +97,8 @@ static void insert_one_record(struct shortlog *log,
>  	}
>  }
>  
> -static int parse_stdin_author(struct shortlog *log,
> -			       struct strbuf *out, const char *in)
> +static int parse_stdin_ident(struct shortlog *log,
> +			     struct strbuf *out, const char *in)
>  {
>  	const char *mailbuf, *namebuf;
>  	size_t namelen, maillen;
> @@ -122,18 +122,18 @@ static int parse_stdin_author(struct shortlog *log,
>  
>  static void read_from_stdin(struct shortlog *log)
>  {
> -	struct strbuf author = STRBUF_INIT;
> -	struct strbuf mapped_author = STRBUF_INIT;
> +	struct strbuf ident = STRBUF_INIT;
> +	struct strbuf mapped_ident = STRBUF_INIT;
>  	struct strbuf oneline = STRBUF_INIT;
>  	static const char *author_match[2] = { "Author: ", "author " };
>  	static const char *committer_match[2] = { "Commit: ", "committer " };
>  	const char **match;
>  
>  	match = log->committer ? committer_match : author_match;
> -	while (strbuf_getline_lf(&author, stdin) != EOF) {
> +	while (strbuf_getline_lf(&ident, stdin) != EOF) {
>  		const char *v;
> -		if (!skip_prefix(author.buf, match[0], &v) &&
> -		    !skip_prefix(author.buf, match[1], &v))
> +		if (!skip_prefix(ident.buf, match[0], &v) &&
> +		    !skip_prefix(ident.buf, match[1], &v))
>  			continue;
>  		while (strbuf_getline_lf(&oneline, stdin) != EOF &&
>  		       oneline.len)
> @@ -142,20 +142,20 @@ static void read_from_stdin(struct shortlog *log)
>  		       !oneline.len)
>  			; /* discard blanks */
>  
> -		strbuf_reset(&mapped_author);
> -		if (parse_stdin_author(log, &mapped_author, v) < 0)
> +		strbuf_reset(&mapped_ident);
> +		if (parse_stdin_ident(log, &mapped_ident, v) < 0)
>  			continue;
>  
> -		insert_one_record(log, mapped_author.buf, oneline.buf);
> +		insert_one_record(log, mapped_ident.buf, oneline.buf);
>  	}
> -	strbuf_release(&author);
> -	strbuf_release(&mapped_author);
> +	strbuf_release(&ident);
> +	strbuf_release(&mapped_ident);
>  	strbuf_release(&oneline);
>  }
>  
>  void shortlog_add_commit(struct shortlog *log, struct commit *commit)
>  {
> -	struct strbuf author = STRBUF_INIT;
> +	struct strbuf ident = STRBUF_INIT;
>  	struct strbuf oneline = STRBUF_INIT;
>  	struct pretty_print_context ctx = {0};
>  	const char *fmt;
> @@ -170,17 +170,17 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
>  		(log->email ? "%cN <%cE>" : "%cN") :
>  		(log->email ? "%aN <%aE>" : "%aN");
>  
> -	format_commit_message(commit, fmt, &author, &ctx);
> +	format_commit_message(commit, fmt, &ident, &ctx);
>  	if (!log->summary) {
>  		if (log->user_format)
>  			pretty_print_commit(&ctx, commit, &oneline);
>  		else
>  			format_commit_message(commit, "%s", &oneline, &ctx);
>  	}
>  
> -	insert_one_record(log, author.buf, oneline.len ? oneline.buf : "<none>");
> +	insert_one_record(log, ident.buf, oneline.len ? oneline.buf : "<none>");
>  
> -	strbuf_release(&author);
> +	strbuf_release(&ident);
>  	strbuf_release(&oneline);
>  }
Previous: Jeff KingNext: Jeff King
Message 26 of 44 in “parsing trailers with shortlog”
  1. 0/8 parsing trailers with shortlogJeff King, Sep 25, 2020
  2. 1/8 shortlog: change "author" variables to "ident"Jeff King, Sep 25, 2020
  3. 2/8 shortlog: refactor committer/author groupingJeff King, Sep 25, 2020
  4. Eric SunshineSep 25, 2020
  5. Jeff KingSep 27, 2020
  6. Jeff KingSep 27, 2020
  7. Eric SunshineSep 27, 2020
  8. Martin ÅgrenSep 26, 2020
  9. Jeff KingSep 27, 2020
  10. 3/8 trailer: add interface for iterating over commit trailersJeff King, Sep 25, 2020
  11. Martin ÅgrenSep 26, 2020
  12. Jeff KingSep 27, 2020
  13. 4/8 shortlog: match commit trailers with --groupJeff King, Sep 25, 2020
  14. 5/8 shortlog: de-duplicate trailer valuesJeff King, Sep 25, 2020
  15. 6/8 shortlog: rename parse_stdin_ident()Jeff King, Sep 25, 2020
  16. 7/8 shortlog: parse trailer identsJeff King, Sep 25, 2020
  17. 8/8 shortlog: allow multiple groups to be specifiedJeff King, Sep 25, 2020
  18. Eric SunshineSep 25, 2020
  19. Jeff KingSep 27, 2020
  20. Martin ÅgrenSep 26, 2020
  21. Jeff KingSep 27, 2020
  22. Derrick StoleeSep 25, 2020
  23. Junio C HamanoSep 25, 2020
  24. 0/8 parsing trailers with shortlogJeff King, Sep 27, 2020
  25. 1/8 shortlog: change "author" variables to "ident"Jeff King, Sep 27, 2020
  26. Junio C HamanoSep 27, 2020
  27. 2/8 shortlog: add grouping optionJeff King, Sep 27, 2020
  28. 3/8 trailer: add interface for iterating over commit trailersJeff King, Sep 27, 2020
  29. 4/8 shortlog: match commit trailers with --groupJeff King, Sep 27, 2020
  30. Junio C HamanoSep 27, 2020
  31. Jeff KingSep 28, 2020
  32. Junio C HamanoSep 28, 2020
  33. 5/8 shortlog: de-duplicate trailer valuesJeff King, Sep 27, 2020
  34. Junio C HamanoSep 27, 2020
  35. Jeff KingSep 28, 2020
  36. 6/8 shortlog: rename parse_stdin_ident()Jeff King, Sep 27, 2020
  37. 7/8 shortlog: parse trailer identsJeff King, Sep 27, 2020
  38. Junio C HamanoSep 27, 2020
  39. 8/8 shortlog: allow multiple groups to be specifiedJeff King, Sep 27, 2020
  40. Junio C HamanoSep 27, 2020
  41. Jeff KingSep 28, 2020
  42. Junio C HamanoDec 28, 2020
  43. Junio C HamanoFeb 4, 2021
  44. Martin ÅgrenSep 27, 2020

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.