Re: Odd broken "--date=now" behavior in current git
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 15, 2015, 17:04 UTC
- Message-ID
- <xmqqzj69l3uw.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <CA+55aFwbEnneEvUDhxGaWw=fSwY2WbtGy6Uc3aQzpiUY6GH1uQ@mail.gmail.com>
Linus Torvalds <torvalds@linux-foundation.org> writes:
Show 6 quoted lines
> On Wed, Apr 15, 2015 at 12:22 AM, Eric Sunshine <sunshine@sunshineco.com> wrote: >> >> The fix seems to be simply: > > Yup, that seems to do it for me. I'm not sure how we get to > "match_digit()" with the time string "now", though.
The --date=<when> parameter is read by determine_author_info() and then parse_force_date(), both in builtin/commit.c. This calls parse_date(), which first calls (and fails) parse_date_basic() when it is not a strict timestamp.
"now", "4.days.ago", etc. are then passed to approxidate_careful() which in turn calls approxidate_str(). Note that the approxidate formats do not usually spell out the TZ offset. The result is turned into "@<numseconds>" by parse_force_date().
The string "@<numseconds>" without TZ offset is re-interpreted by parse_date() called by fmt_ident(); the last function prepares the author ident line "Name <email> <numseconds> <offset>".
The --date=<when> does not force committer information, which goes through the usual codepath of grabbing the "current" time.