Re: [PATCH v2 2/6] date: make "local" orthogonal to date format
- From
John Keeping <john@keeping.me.uk>
- Date
- Sep 1, 2015, 22:33 UTC
- Message-ID
- <20150901223308.GI30659@serenity.lan>
- In-Reply-To
- <xmqqwpw9pyy5.fsf@gitster.mtv.corp.google.com>
On Tue, Sep 01, 2015 at 03:16:50PM -0700, Junio C Hamano wrote:
Show 9 quoted lines
> John Keeping <john@keeping.me.uk> writes: > > > This is Jeff's original patch with my fixup for DATE_STRFTIME squashed > > in and a new change to reject "raw-local" (in both Documentation/ and > > date.c). > > Even in --date=raw, we do show the timezone offset, so I do not > necessarily agree that raw-local is nonsensical. That's the only > difference between the one I queued yesterday and this one.
I suspect it depends on the interpretation of "raw"; the code currently interprets raw to mean "exactly what exists in the commit/tag", in which case converting it to the local timezone is wrong. But the documentation describes "raw" as "the raw Git %s %z format", and if we interpret it to mean "Git's internal date format" then "raw-local" makes sense.
The alternative would be the patch below as a preparatory step.
-- >8 --
diff --git a/date.c b/date.c index f048416..345890f 100644 --- a/date.c +++ b/date.c @@ -175,12 +175,6 @@ const char *show_date(unsigned long time, int tz, const struct date_mode *mode) struct tm *tm; static struct strbuf timebuf = STRBUF_INIT; - if (mode->type == DATE_RAW) { - strbuf_reset(&timebuf); - strbuf_addf(&timebuf, "%lu %+05d", time, tz); - return timebuf.buf; - } - if (mode->type == DATE_RELATIVE) { struct timeval now; @@ -193,6 +187,12 @@ const char *show_date(unsigned long time, int tz, const struct date_mode *mode) if (mode->local) tz = local_tzoffset(time); + if (mode->type == DATE_RAW) { + strbuf_reset(&timebuf); + strbuf_addf(&timebuf, "%lu %+05d", time, tz); + return timebuf.buf; + } + tm = time_to_tm(time, tz); if (!tm) { tm = time_to_tm(0, 0);