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

[PATCH 1/2] for each ref add a raw timestamp field type

From
Andy Whitcroft <apw@shadowen.org>
Date
Sep 20, 2006, 10:31 UTC
Message-ID
<20060920103119.GA30145@shadowen.org>
In-Reply-To
<4511173D.7020702@shadowen.org>
for-each-ref: add a raw timestamp field type

cvsimport is interested in the raw time stamps (in seconds since the epoch) to do its time comparisons. Export the raw timestamp under {author,committer,tagger}stamp.

Signed-off-by: Andy Whitcroft <apw@shadowen.org>
---
diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
index 698618b..9d6c4f0 100644
--- a/builtin-for-each-ref.c
+++ b/builtin-for-each-ref.c
@@ -51,14 +51,17 @@ static struct {
 	{ "authorname" },
 	{ "authoremail" },
 	{ "authordate", FIELD_TIME },
+	{ "authorstamp", FIELD_TIME },
 	{ "committer" },
 	{ "committername" },
 	{ "committeremail" },
 	{ "committerdate", FIELD_TIME },
+	{ "committerstamp", FIELD_TIME },
 	{ "tagger" },
 	{ "taggername" },
 	{ "taggeremail" },
 	{ "taggerdate", FIELD_TIME },
+	{ "taggerstamp", FIELD_TIME },
 	{ "subject" },
 	{ "body" },
 	{ "contents" },
@@ -344,9 +347,10 @@ static char *copy_email(const char *buf)
 	return line;
 }
 
-static void grab_date(const char *buf, struct atom_value *v)
+static void grab_date(const char *buf, struct atom_value *v, int raw)
 {
 	const char *eoemail = strstr(buf, "> ");
+	const char *eol = strchr(buf, '\n');
 	char *zone;
 	unsigned long timestamp;
 	long tz;
@@ -359,7 +363,15 @@ static void grab_date(const char *buf, s
 	tz = strtol(zone, NULL, 10);
 	if ((tz == LONG_MIN || tz == LONG_MAX) && errno == ERANGE)
 		goto bad;
-	v->s = xstrdup(show_date(timestamp, tz, 0));
+	if (raw) {
+		int len = (eol - eoemail - 2);
+		char *stamp = xmalloc(len + 1);
+
+		memcpy(stamp, eoemail + 2, len);
+		stamp[len] = 0;
+		v->s = stamp;
+	} else
+		v->s = xstrdup(show_date(timestamp, tz, 0));
 	v->ul = timestamp;
 	return;
  bad:
@@ -386,7 +398,8 @@ static void grab_person(const char *who,
 		if (name[wholen] != 0 &&
 		    strcmp(name + wholen, "name") &&
 		    strcmp(name + wholen, "email") &&
-		    strcmp(name + wholen, "date"))
+		    strcmp(name + wholen, "date") &&
+		    strcmp(name + wholen, "stamp"))
 			continue;
 		if (!wholine)
 			wholine = find_wholine(who, wholen, buf, sz);
@@ -399,7 +412,9 @@ static void grab_person(const char *who,
 		else if (!strcmp(name + wholen, "email"))
 			v->s = copy_email(wholine);
 		else if (!strcmp(name + wholen, "date"))
-			grab_date(wholine, v);
+			grab_date(wholine, v, 0);
+		else if (!strcmp(name + wholen, "stamp"))
+			grab_date(wholine, v, 1);
 	}
 }
 
Previous: Andy WhitcroftNext: Andy Whitcroft
Message 4 of 15 in “cvsimport move over to using git for each ref to read refs”
  1. cvsimport move over to using git for each ref to read refsAndy Whitcroft, Sep 20, 2006
  2. Jakub NarebskiSep 20, 2006
  3. Andy WhitcroftSep 20, 2006
  4. 1/2 for each ref add a raw timestamp field typeAndy Whitcroft, Sep 20, 2006
  5. 2/2 cvsimport move over to using git for each ref to read refs V2Andy Whitcroft, Sep 20, 2006
  6. Jakub NarebskiSep 20, 2006
  7. Junio C HamanoSep 20, 2006
  8. Andy WhitcroftSep 20, 2006
  9. cvsimport move over to using git for each ref to read refs V3Andy Whitcroft, Sep 20, 2006
  10. Junio C HamanoSep 20, 2006
  11. Andy WhitcroftSep 20, 2006
  12. Junio C HamanoSep 20, 2006
  13. Junio C HamanoSep 20, 2006
  14. Andy WhitcroftSep 21, 2006
  15. Junio C HamanoSep 22, 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.