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

[PATCH 1/2] for-each-ref: "creator" and "creatordate" fields

From
Jakub Narebski <jnareb@gmail.com>
Date
Nov 2, 2006, 19:17 UTC
Message-ID
<200611022017.31351.jnareb@gmail.com>
In-Reply-To
<7vslh86uz9.fsf@assigned-by-dhcp.cox.net>
From fa1a32c9a7c8a31b122df7d07f4a8885cbe120d0 Mon Sep 17 00:00:00 2001
From: Junio C Hamano <junkio@cox.net>
Date: Sat, 28 Oct 2006 13:33:46 -0700
Subject: [PATCH 1/2] for-each-ref: "creator" and "creatordate" fields

This adds "creator" (which is parallel to "tagger" or "committer") and "creatordate" (corresponds to "taggerdate" and "committerdate").

As other "date" fields, "creatordate" sorts numerically and displays human readably. This allows for example for sorting together heavyweigth and lightweight tags.

[jn: originally fields were named "epoch" and "epochdate".]
Signed-off-by: Junio C Hamano <junkio@cox.net>
Acked-by: Jakub Narebski <jnareb@gmail.com>
---
 builtin-for-each-ref.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
index 93d3d7e..173bf38 100644
--- a/builtin-for-each-ref.c
+++ b/builtin-for-each-ref.c
@@ -59,6 +59,8 @@ static struct {
 	{ "taggername" },
 	{ "taggeremail" },
 	{ "taggerdate", FIELD_TIME },
+	{ "creator" },
+	{ "creatordate", FIELD_TIME },
 	{ "subject" },
 	{ "body" },
 	{ "contents" },
@@ -401,6 +403,29 @@ static void grab_person(const char *who,
 		else if (!strcmp(name + wholen, "date"))
 			grab_date(wholine, v);
 	}
+
+	/* For a tag or a commit object, if "creator" or "creatordate" is
+	 * requested, do something special.
+	 */
+	if (strcmp(who, "tagger") && strcmp(who, "committer"))
+		return; /* "author" for commit object is not wanted */
+	if (!wholine)
+		wholine = find_wholine(who, wholen, buf, sz);
+	if (!wholine)
+		return;
+	for (i = 0; i < used_atom_cnt; i++) {
+		const char *name = used_atom[i];
+		struct atom_value *v = &val[i];
+		if (!!deref != (*name == '*'))
+			continue;
+		if (deref)
+			name++;
+
+		if (!strcmp(name, "creatordate"))
+			grab_date(wholine, v);
+		else if (!strcmp(name, "creator"))
+			v->s = copy_line(wholine);
+	}
 }
 
 static void find_subpos(const char *buf, unsigned long sz, const char **sub, const char **body)
-- 
1.4.3.3
Previous: Johannes SchindelinNext: Jakub Narebski
Message 9 of 15 in “Documentation: Update information about <format> in git-for-each-ref”
  1. Documentation: Update information about <format> in git-for-each-refJakub Narebski, Oct 28, 2006
  2. Junio C HamanoOct 28, 2006
  3. Jakub NarebskiOct 28, 2006
  4. Andreas EricssonNov 1, 2006
  5. Junio C HamanoNov 1, 2006
  6. Andreas EricssonNov 1, 2006
  7. Junio C HamanoNov 1, 2006
  8. Johannes SchindelinNov 1, 2006
  9. 1/2 for-each-ref: "creator" and "creatordate" fieldsJakub Narebski, Nov 2, 2006
  10. 2/2 gitweb: Use git-for-each-ref to generate list of heads and/or tagsJakub Narebski, Nov 2, 2006
  11. Junio C HamanoNov 3, 2006
  12. Jakub NarebskiNov 3, 2006
  13. Junio C HamanoNov 3, 2006
  14. Jakub NarebskiNov 3, 2006
  15. Junio C HamanoOct 28, 2006

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.