[PATCH 1/3] log: Show reflog date with --date=normal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The reflog case special-cases --date=default (internally DATE_NORMAL)
to show the entry number instead of a date.  This means it is
impossible to show the default date format for the reflog entries.

Introduce a new state DATE_DEFAULT (for the existing --date=default)
that takes over the special value 0, and have DATE_NORMAL (for the new
--date=normal) act the same except in the reflog code where we still
special-case the value 0.  This means that 'git log -g --date=normal'
shows the date, whereas 'git log -g --date=default' shows the reflog
entry number.

Thanks to Johannes Schindelin for IRC help.

Signed-off-by: Thomas Rast <trast@xxxxxxxxxxxxxxx>
---
 Documentation/git-rev-list.txt     |    2 +-
 Documentation/rev-list-options.txt |    7 +++++--
 builtin-blame.c                    |    1 +
 cache.h                            |    3 ++-
 date.c                             |    2 ++
 5 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt
index a765cfa..6f2013b 100644
--- a/Documentation/git-rev-list.txt
+++ b/Documentation/git-rev-list.txt
@@ -36,7 +36,7 @@ SYNOPSIS
 	     [ \--regexp-ignore-case | -i ]
 	     [ \--extended-regexp | -E ]
 	     [ \--fixed-strings | -F ]
-	     [ \--date={local|relative|default|iso|rfc|short} ]
+	     [ \--date={local|relative|normal|default|iso|rfc|short} ]
 	     [ [\--objects | \--objects-edge] [ \--unpacked ] ]
 	     [ \--pretty | \--header ]
 	     [ \--bisect ]
diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
index bf66116..2a106bd 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,raw}::
+--date={relative,local,normal,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
@@ -33,8 +33,11 @@ format, often found in E-mail messages.
 +
 `--date=raw` shows the date in the internal raw git format `%s %z` format.
 +
-`--date=default` shows timestamps in the original timezone
+`--date=normal` shows timestamps in the original timezone
 (either committer's or author's).
++
+`--date=default` is like `normal`, except for reflog entries where the
+entry number is shown instead.
 
 ifdef::git-rev-list[]
 --header::
diff --git a/builtin-blame.c b/builtin-blame.c
index fd6ca51..9671c20 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -2288,6 +2288,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
 		/* "normal" is used as the fallback for "relative" */
 	case DATE_LOCAL:
 	case DATE_NORMAL:
+	case DATE_DEFAULT:
 		blame_date_width = sizeof("Thu Oct 19 16:00:04 2006 -0700");
 		break;
 	}
diff --git a/cache.h b/cache.h
index e6c7f33..a62ce78 100644
--- a/cache.h
+++ b/cache.h
@@ -712,7 +712,8 @@ static inline unsigned int hexval(unsigned char c)
 				   struct object *o, enum object_type);
 
 enum date_mode {
-	DATE_NORMAL = 0,
+	DATE_DEFAULT = 0,
+	DATE_NORMAL,
 	DATE_RELATIVE,
 	DATE_SHORT,
 	DATE_LOCAL,
diff --git a/date.c b/date.c
index 409a17d..661dd24 100644
--- a/date.c
+++ b/date.c
@@ -637,6 +637,8 @@ enum date_mode parse_date_format(const char *format)
 	else if (!strcmp(format, "local"))
 		return DATE_LOCAL;
 	else if (!strcmp(format, "default"))
+		return DATE_DEFAULT;
+	else if (!strcmp(format, "normal"))
 		return DATE_NORMAL;
 	else if (!strcmp(format, "raw"))
 		return DATE_RAW;
-- 
1.6.4.rc3.218.gb7ac

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]