• Jeff King's avatar
    commit: accept more date formats for "--date" · 14ac2864
    Jeff King authored
    Right now we pass off the string found by "--date" straight
    to the fmt_ident function, which will use our strict
    parse_date to normalize it. However, this means obvious
    things like "--date=now" or "--date=2.days.ago" will not
    work.
    
    Instead, let's fallback to the approxidate function to
    handle this for us. Note that we must try parse_date
    ourselves first, even though approxidate will try strict
    parsing itself. The reason is that approxidate throws away
    any timezone information it sees from the strict parsing,
    and we want to preserve it. So asking for:
    
      git commit --date="@1234567890 -0700"
    
    continues to set the date in -0700, regardless of what the
    local timezone is.
    Signed-off-by: default avatarJeff King <peff@peff.net>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    14ac2864
t7501-commit.sh 13.9 KB