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

[CLEANUP PATCH] show <tag>: reuse pp_user_info() instead of duplicating code

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jan 2, 2009, 18:08 UTC
Message-ID
<alpine.DEB.1.00.0901021717350.27818@racer>

We used to extract the tagger information "by hand" in "git show <tag>", but the function pp_user_info() already does that. Even better: it respects the commit_format and date_format specified by the user.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
	Just a little cleanup, as I tripped over that part of Git's source.
 builtin-log.c |   21 ++++++---------------
 1 files changed, 6 insertions(+), 15 deletions(-)
diff --git a/builtin-log.c b/builtin-log.c
index 99d1137..bc4e1e9 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -249,22 +249,13 @@ int cmd_whatchanged(int argc, const char **argv, const char *prefix)
 
 static void show_tagger(char *buf, int len, struct rev_info *rev)
 {
-	char *email_end, *p;
-	unsigned long date;
-	int tz;
+	struct strbuf out = STRBUF_INIT;
 
-	email_end = memchr(buf, '>', len);
-	if (!email_end)
-		return;
-	p = ++email_end;
-	while (isspace(*p))
-		p++;
-	date = strtoul(p, &p, 10);
-	while (isspace(*p))
-		p++;
-	tz = (int)strtol(p, NULL, 10);
-	printf("Tagger: %.*s\nDate:   %s\n", (int)(email_end - buf), buf,
-	       show_date(date, tz, rev->date_mode));
+	pp_user_info("Tagger", rev->commit_format, &out, buf, rev->date_mode,
+		git_log_output_encoding ?
+		git_log_output_encoding: git_commit_encoding);
+	printf("%s\n", out.buf);
+	strbuf_release(&out);
 }
 
 static int show_object(const unsigned char *sha1, int show_tag_object,
-- 
1.6.1.rc3.224.g95ac9
Next: Junio C Hamano
Message 1 of 2 in “show <tag>: reuse pp_user_info() instead of duplicating code”
  1. show <tag>: reuse pp_user_info() instead of duplicating codeJohannes Schindelin, Jan 2, 2009
  2. Junio C HamanoJan 6, 2009

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.