From b7242b8c9e4b3c57a07c2a76d0337389605aadcc Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 1 May 2014 21:10:01 -0400 Subject: 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 Signed-off-by: Junio C Hamano --- t/t7502-commit.sh | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 't/t7502-commit.sh') diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh index 9a3f3a1b41..6465cd59af 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 && -- cgit v1.2.1