summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2014-05-01 21:12:42 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2014-05-02 14:15:22 -0700
commit14ac2864dcd566a025e449ab9db6b5dc57744a32 (patch)
tree59b940b6d6c267cf8cd80069d530f15175051686 /t
parentcommit: print "Date" line when the user has set date (diff)
downloadtgif-14ac2864dcd566a025e449ab9db6b5dc57744a32.tar.xz
commit: accept more date formats for "--date"
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: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t7501-commit.sh12
1 files changed, 10 insertions, 2 deletions
diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index 5a76823d4c..63e04277f9 100755
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
@@ -351,8 +351,16 @@ test_expect_success 'commit mentions forced date in output' '
grep "Date: *Sat Jan 2 03:04:05 2010" output
'
-test_expect_success 'commit complains about bogus date' '
- test_must_fail git commit --amend --date=10.11.2010
+test_expect_success 'commit complains about completely bogus dates' '
+ test_must_fail git commit --amend --date=seventeen
+'
+
+test_expect_success 'commit --date allows approxidate' '
+ git commit --amend \
+ --date="midnight the 12th of october, anno domini 1979" &&
+ echo "Fri Oct 12 00:00:00 1979 +0000" >expect &&
+ git log -1 --format=%ad >actual &&
+ test_cmp expect actual
'
test_expect_success 'sign off (1)' '