t7502: narrow checks for author/committer name in template

t7502.20 and t7502.21 check that the author and committer name are mentioned in the commit message template under certain circumstances. However, they end up checking a much larger and unnecessary portion of the template. Let's narrow their checks to the specific lines. While we're at it, let's give these tests more descriptive names, so their purposes are more obvious. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jul 26, 2012 at 16:30 UTC 1f4bf34578e93e8f5fa06652695e839bc51ea90f
1 file changed +8 -17
t/t7502-commit.sh
+8 -17
@@ -235,24 +235,15 @@ test_expect_success 'cleanup commit messages (strip,-F,-e): output' '
235 test_i18ncmp expect actual
236 '
237
238 -echo "#
239 -# Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
240 -#" >> expect
241 -
242 -test_expect_success 'author different from committer' '
238 +test_expect_success 'message shows author when it is not equal to committer' '
239 echo >>negative &&
240 test_might_fail git commit -e -m "sample" &&
245 - head -n 7 .git/COMMIT_EDITMSG >actual &&
246 - test_i18ncmp expect actual
241 + test_i18ngrep \
242 + "^# Author: *A U Thor <author@example.com>\$" \
243 + .git/COMMIT_EDITMSG
244 '
245
249 -mv expect expect.tmp
250 -sed '$d' < expect.tmp > expect
251 -rm -f expect.tmp
252 -echo "# Committer:
253 -#" >> expect
254 -
255 -test_expect_success 'committer is automatic' '
246 +test_expect_success 'message shows committer when it is automatic' '
247
248 echo >>negative &&
249 (
@@ -261,9 +252,9 @@ test_expect_success 'committer is automatic' '
252 # must fail because there is no change
253 test_must_fail git commit -e -m "sample"
254 ) &&
264 - head -n 8 .git/COMMIT_EDITMSG | \
265 - sed "s/^# Committer: .*/# Committer:/" >actual
266 - test_i18ncmp expect actual
255 + # the ident is calculated from the system, so we cannot
256 + # check the actual value, only that it is there
257 + test_i18ngrep "^# Committer: " .git/COMMIT_EDITMSG
258 '
259
260 write_script .git/FAKE_EDITOR <<EOF