Git development
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: eletuchy@gmail.com
Cc: gitster@pobox.com, peff@peff.net, git@vger.kernel.org,
	eletuchy@facebook.com, Eugene Letuchy <eugene@facebook.com>
Subject: Re: [PATCH 2/2] --date=relative falls back to "short" format for commits older than a year
Date: Fri, 20 Feb 2009 14:15:22 -0800 (PST)	[thread overview]
Message-ID: <alpine.LFD.2.00.0902201409230.21686@localhost.localdomain> (raw)
In-Reply-To: <1235165034-20299-1-git-send-email-eletuchy@gmail.com>


Subject: Support 'raw' date format

Talking about --date, one thing I wanted for the 1234567890 date was to 
get things in the raw format. Sure, you get them with --pretty=raw, but it 
felt a bit sad that you couldn't just ask for the date in raw format.

So here's a throw-away patch (meaning: I won't be re-sending it, because I 
really don't think it's a big deal) to add "--date=raw". It just prints 
out the internal raw git format - seconds since epoch plus timezone (put 
another way: 'date +"%s %z"' format)

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---

Not a whole lot of testing. But 

	git show --date=raw v2.6.29-rc5

works correctly.

 Documentation/rev-list-options.txt |    4 +++-
 cache.h                            |    3 ++-
 date.c                             |    7 +++++++
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git i/Documentation/rev-list-options.txt w/Documentation/rev-list-options.txt
index b9f6e4d..5076322 100644
--- i/Documentation/rev-list-options.txt
+++ w/Documentation/rev-list-options.txt
@@ -13,7 +13,7 @@ include::pretty-options.txt[]
 
 	Synonym for `--date=relative`.
 
---date={relative,local,default,iso,rfc,short}::
+--date={relative,local,default,iso,rfc,short,raw}::
 
 	Only takes effect for dates shown in human-readable format, such
 	as when using "--pretty". `log.date` config variable sets a default
@@ -31,6 +31,8 @@ format, often found in E-mail messages.
 +
 `--date=short` shows only date but not time, in `YYYY-MM-DD` format.
 +
+`--date=raw` shows the date in the internal raw git format `%s %z` format.
++
 `--date=default` shows timestamps in the original timezone
 (either committer's or author's).
 
diff --git i/cache.h w/cache.h
index 21a6310..189151d 100644
--- i/cache.h
+++ w/cache.h
@@ -696,7 +696,8 @@ enum date_mode {
 	DATE_SHORT,
 	DATE_LOCAL,
 	DATE_ISO8601,
-	DATE_RFC2822
+	DATE_RFC2822,
+	DATE_RAW
 };
 
 const char *show_date(unsigned long time, int timezone, enum date_mode mode);
diff --git i/date.c w/date.c
index 950b88f..d75dff4 100644
--- i/date.c
+++ w/date.c
@@ -89,6 +89,11 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)
 	struct tm *tm;
 	static char timebuf[200];
 
+	if (mode == DATE_RAW) {
+		snprintf(timebuf, sizeof(timebuf), "%lu %+05d", time, tz);
+		return timebuf;
+	}
+
 	if (mode == DATE_RELATIVE) {
 		unsigned long diff;
 		struct timeval now;
@@ -615,6 +620,8 @@ enum date_mode parse_date_format(const char *format)
 		return DATE_LOCAL;
 	else if (!strcmp(format, "default"))
 		return DATE_NORMAL;
+	else if (!strcmp(format, "raw"))
+		return DATE_RAW;
 	else
 		die("unknown date format %s", format);
 }

  reply	other threads:[~2009-02-20 22:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-20 21:23 [PATCH 2/2] --date=relative falls back to "short" format for commits older than a year eletuchy
2009-02-20 22:15 ` Linus Torvalds [this message]
2009-02-20 22:47   ` Eugene Letuchy
2009-02-21  5:48   ` Junio C Hamano
2009-02-22 23:06 ` Jeff King
2009-02-23  1:44   ` Junio C Hamano
2009-02-23  3:16     ` Jeff King
2009-02-23  8:09       ` Marius Storm-Olsen
2009-02-24  5:04         ` Jeff King
2009-02-24  6:35           ` Marius Storm-Olsen
2009-02-24  6:36             ` Jeff King
2009-02-23 16:33       ` Junio C Hamano
2009-02-24  5:42         ` Jeff King
2009-02-24  6:59           ` Junio C Hamano
2009-02-24  7:07             ` Jeff King

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=alpine.LFD.2.00.0902201409230.21686@localhost.localdomain \
    --to=torvalds@linux-foundation.org \
    --cc=eletuchy@facebook.com \
    --cc=eletuchy@gmail.com \
    --cc=eugene@facebook.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /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