summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2014-05-02 01:10:01 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-05-02 21:14:21 (GMT)
commitb7242b8c9e4b3c57a07c2a76d0337389605aadcc (patch)
tree34772e47e05d428e7608ee04f5922ff56f4c1539 /t
parentd1053246554d176173893a5283dc0c0fb563ed03 (diff)
downloadgit-b7242b8c9e4b3c57a07c2a76d0337389605aadcc.zip
git-b7242b8c9e4b3c57a07c2a76d0337389605aadcc.tar.gz
git-b7242b8c9e4b3c57a07c2a76d0337389605aadcc.tar.bz2
commit: print "Date" line when the user has set date
When we make a commit and the author is not the same as the committer (e.g., because you used "-c $commit" or "--author=$somebody"), we print the author's name and email in both the commit-message template and as part of the commit summary. This is a safety check to give the user a chance to confirm that we are doing what they expect. This patch brings the same safety for the "date" field, which may be set by "-c" or by using "--date". Note that we explicitly do not set it for $GIT_AUTHOR_DATE, as it is probably not of interest when "git commit" is being fed its parameters by a script. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t3508-cherry-pick-many-commits.sh6
-rwxr-xr-xt/t7501-commit.sh5
-rwxr-xr-xt/t7502-commit.sh7
3 files changed, 18 insertions, 0 deletions
diff --git a/t/t3508-cherry-pick-many-commits.sh b/t/t3508-cherry-pick-many-commits.sh
index 19c99d7..b457333 100755
--- a/t/t3508-cherry-pick-many-commits.sh
+++ b/t/t3508-cherry-pick-many-commits.sh
@@ -65,12 +65,15 @@ test_expect_success 'output to keep user entertained during multi-pick' '
cat <<-\EOF >expected &&
[master OBJID] second
Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:14:13 2005 -0700
1 file changed, 1 insertion(+)
[master OBJID] third
Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:15:13 2005 -0700
1 file changed, 1 insertion(+)
[master OBJID] fourth
Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:16:13 2005 -0700
1 file changed, 1 insertion(+)
EOF
@@ -98,14 +101,17 @@ test_expect_success 'output during multi-pick indicates merge strategy' '
Trying simple merge.
[master OBJID] second
Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:14:13 2005 -0700
1 file changed, 1 insertion(+)
Trying simple merge.
[master OBJID] third
Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:15:13 2005 -0700
1 file changed, 1 insertion(+)
Trying simple merge.
[master OBJID] fourth
Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:16:13 2005 -0700
1 file changed, 1 insertion(+)
EOF
diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index d58b097..5a76823 100755
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
@@ -346,6 +346,11 @@ test_expect_success 'amend commit to fix date' '
'
+test_expect_success 'commit mentions forced date in output' '
+ git commit --amend --date=2010-01-02T03:04:05 >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
'
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh
index 9a3f3a1..6465cd5 100755
--- a/t/t7502-commit.sh
+++ b/t/t7502-commit.sh
@@ -344,6 +344,13 @@ test_expect_success 'message shows author when it is not equal to committer' '
.git/COMMIT_EDITMSG
'
+test_expect_success 'message shows date when it is explicitly set' '
+ git commit --allow-empty -e -m foo --date="2010-01-02T03:04:05" &&
+ test_i18ngrep \
+ "^# Date: *Sat Jan 2 03:04:05 2010 +0000" \
+ .git/COMMIT_EDITMSG
+'
+
test_expect_success AUTOIDENT 'message shows committer when it is automatic' '
echo >>negative &&