git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Whitcroft <apw@shadowen.org>
To: git@vger.kernel.org
Subject: [PATCH 1/2] for each ref add a raw timestamp field type
Date: Wed, 20 Sep 2006 11:31:19 +0100	[thread overview]
Message-ID: <20060920103119.GA30145@shadowen.org> (raw)
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);
 	}
 }
 

  reply	other threads:[~2006-09-20 10:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-20  8:52 [PATCH] cvsimport move over to using git for each ref to read refs Andy Whitcroft
2006-09-20  9:23 ` Jakub Narebski
2006-09-20 10:26   ` Andy Whitcroft
2006-09-20 10:31     ` Andy Whitcroft [this message]
2006-09-20 10:31     ` [PATCH 2/2] cvsimport move over to using git for each ref to read refs V2 Andy Whitcroft
2006-09-20 11:00     ` [PATCH] cvsimport move over to using git for each ref to read refs Jakub Narebski
2006-09-20 15:53     ` Junio C Hamano
2006-09-20 16:12       ` Andy Whitcroft
2006-09-20 16:37         ` [PATCH] cvsimport move over to using git for each ref to read refs V3 Andy Whitcroft
2006-09-20 16:55           ` Junio C Hamano
2006-09-20 17:00             ` Andy Whitcroft
2006-09-20 17:17               ` Junio C Hamano
2006-09-20 16:45         ` [PATCH] cvsimport move over to using git for each ref to read refs Junio C Hamano
2006-09-21 12:06           ` Andy Whitcroft
2006-09-22  4:57             ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060920103119.GA30145@shadowen.org \
    --to=apw@shadowen.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).