summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-02-20 22:15:22 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-02-21 05:45:42 (GMT)
commit7dff9b30ea0603fe265f9f7da055fc34f5d57d2f (patch)
treea59ae4b1012d9e64a74e5cde457f3f9eb12da2e6
parent8c5b85ce87d15e4db37a6408f03b0eb71dde080e (diff)
downloadgit-7dff9b30ea0603fe265f9f7da055fc34f5d57d2f.zip
git-7dff9b30ea0603fe265f9f7da055fc34f5d57d2f.tar.gz
git-7dff9b30ea0603fe265f9f7da055fc34f5d57d2f.tar.bz2
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--Documentation/rev-list-options.txt4
-rw-r--r--cache.h3
-rw-r--r--date.c7
3 files changed, 12 insertions, 2 deletions
diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
index b9f6e4d..5076322 100644
--- a/Documentation/rev-list-options.txt
+++ b/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 a/cache.h b/cache.h
index 21a6310..189151d 100644
--- a/cache.h
+++ b/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 a/date.c b/date.c
index 950b88f..d75dff4 100644
--- a/date.c
+++ b/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);
}