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

Re: [PATCH] Documentation: Update information about <format> in git-for-each-ref

From
Junio C Hamano <junkio@cox.net>
Date
Oct 28, 2006, 20:33 UTC
Message-ID
<7vslh86uz9.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<200610281930.05889.jnareb@gmail.com>
Jakub Narebski <jnareb@gmail.com> writes:
Show 7 quoted lines
> By the way one thing missing from git-for-each-ref to use it
> in gitweb without changing its output is ablility to sort on
> "epoch", i.e. taggerdate for tags and committerdate for commits.
> This is needed to sort heavyweight and lightweight tags together
> on epoch in "summary" and "tags" views in gitweb. (It is not
> needed for heads/branches, but it is the tags sorting that
> cripples gitweb "summary" view performance.)

I guess something like this, but I haven't tested it heavily. If you want it in "next" please ack (with necessary fix-up patches if any).

-- >8 -- [PATCH] for-each-ref: epoch and epochdate

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

As other "date" fields, "epochdate" sorts numerically and displays human readably

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
index 698618b..3dc68cc 100644
--- a/builtin-for-each-ref.c
+++ b/builtin-for-each-ref.c
@@ -59,6 +59,8 @@ static struct {
 	{ "taggername" },
 	{ "taggeremail" },
 	{ "taggerdate", FIELD_TIME },
+	{ "epoch" },
+	{ "epochdate", 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 "epoch" or "epochdate" 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, "epochdate"))
+			grab_date(wholine, v);
+		else if (!strcmp(name, "epoch"))
+			v->s = copy_line(wholine);
+	}
 }
 
 static void find_subpos(const char *buf, unsigned long sz, const char **sub, const char **body)
Previous: Jakub NarebskiNext: Jakub Narebski
Message 2 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.