diff mbox series

[1/3] t3436: check --committer-date-is-author-date result more carefully

Message ID 20201023070843.GA2913115@coredump.intra.peff.net (mailing list archive)
State New, archived
Headers show
Series [1/3] t3436: check --committer-date-is-author-date result more carefully | expand

Commit Message

Jeff King Oct. 23, 2020, 7:08 a.m. UTC
After running "rebase --committer-date-is-author-date", we confirm that
the committer date is the same as the author date. However, we don't
look at any other parts of the committer ident line to make sure we
didn't screw them up. And indeed, there are a few bugs here. Depending
on the rebase backend in use, we may accidentally use the author email
instead of the committer's, or even an empty string.

Let's teach our test_ctime_is_atime helper to check the committer name
and email, which reveals several failing tests.

Signed-off-by: Jeff King <peff@peff.net>
---
 t/t3436-rebase-more-options.sh | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Phillip Wood Oct. 23, 2020, 10:10 a.m. UTC | #1
Hi Peff

Thanks for fixing this embarrassing mistake and strengthening the tests, 
the first three patches look fine to me. We don't check the committer 
name and email in t4150-am.sh which we probably should do (the rebase 
tests were based on those) though that can wait as some of the rebase 
tests are testing the am implementation.

Thanks again

Phillip

On 23/10/2020 08:08, Jeff King wrote:
> After running "rebase --committer-date-is-author-date", we confirm that
> the committer date is the same as the author date. However, we don't
> look at any other parts of the committer ident line to make sure we
> didn't screw them up. And indeed, there are a few bugs here. Depending
> on the rebase backend in use, we may accidentally use the author email
> instead of the committer's, or even an empty string.
> 
> Let's teach our test_ctime_is_atime helper to check the committer name
> and email, which reveals several failing tests.
> 
> Signed-off-by: Jeff King <peff@peff.net>
> ---
>   t/t3436-rebase-more-options.sh | 14 +++++++-------
>   1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/t/t3436-rebase-more-options.sh b/t/t3436-rebase-more-options.sh
> index 996e82787e..6f2f49717b 100755
> --- a/t/t3436-rebase-more-options.sh
> +++ b/t/t3436-rebase-more-options.sh
> @@ -65,31 +65,31 @@ test_expect_success '--ignore-whitespace is remembered when continuing' '
>   '
>   
>   test_ctime_is_atime () {
> -	git log $1 --format=%ai >authortime &&
> -	git log $1 --format=%ci >committertime &&
> +	git log $1 --format="$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> %ai" >authortime &&
> +	git log $1 --format="%cn <%ce> %ci" >committertime &&
>   	test_cmp authortime committertime
>   }
>   
> -test_expect_success '--committer-date-is-author-date works with apply backend' '
> +test_expect_failure '--committer-date-is-author-date works with apply backend' '
>   	GIT_AUTHOR_DATE="@1234 +0300" git commit --amend --reset-author &&
>   	git rebase --apply --committer-date-is-author-date HEAD^ &&
>   	test_ctime_is_atime -1
>   '
>   
> -test_expect_success '--committer-date-is-author-date works with merge backend' '
> +test_expect_failure '--committer-date-is-author-date works with merge backend' '
>   	GIT_AUTHOR_DATE="@1234 +0300" git commit --amend --reset-author &&
>   	git rebase -m --committer-date-is-author-date HEAD^ &&
>   	test_ctime_is_atime -1
>   '
>   
> -test_expect_success '--committer-date-is-author-date works with rebase -r' '
> +test_expect_failure '--committer-date-is-author-date works with rebase -r' '
>   	git checkout side &&
>   	GIT_AUTHOR_DATE="@1234 +0300" git merge --no-ff commit3 &&
>   	git rebase -r --root --committer-date-is-author-date &&
>   	test_ctime_is_atime
>   '
>   
> -test_expect_success '--committer-date-is-author-date works when forking merge' '
> +test_expect_failure '--committer-date-is-author-date works when forking merge' '
>   	git checkout side &&
>   	GIT_AUTHOR_DATE="@1234 +0300" git merge --no-ff commit3 &&
>   	PATH="./test-bin:$PATH" git rebase -r --root --strategy=test \
> @@ -145,7 +145,7 @@ test_expect_success '--reset-author-date works with rebase -r' '
>   	test_atime_is_ignored
>   '
>   
> -test_expect_success '--reset-author-date with --committer-date-is-author-date works' '
> +test_expect_failure '--reset-author-date with --committer-date-is-author-date works' '
>   	test_must_fail git rebase -m --committer-date-is-author-date \
>   		--reset-author-date --onto commit2^^ commit2^ commit3 &&
>   	git checkout --theirs foo &&
>
diff mbox series

Patch

diff --git a/t/t3436-rebase-more-options.sh b/t/t3436-rebase-more-options.sh
index 996e82787e..6f2f49717b 100755
--- a/t/t3436-rebase-more-options.sh
+++ b/t/t3436-rebase-more-options.sh
@@ -65,31 +65,31 @@  test_expect_success '--ignore-whitespace is remembered when continuing' '
 '
 
 test_ctime_is_atime () {
-	git log $1 --format=%ai >authortime &&
-	git log $1 --format=%ci >committertime &&
+	git log $1 --format="$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> %ai" >authortime &&
+	git log $1 --format="%cn <%ce> %ci" >committertime &&
 	test_cmp authortime committertime
 }
 
-test_expect_success '--committer-date-is-author-date works with apply backend' '
+test_expect_failure '--committer-date-is-author-date works with apply backend' '
 	GIT_AUTHOR_DATE="@1234 +0300" git commit --amend --reset-author &&
 	git rebase --apply --committer-date-is-author-date HEAD^ &&
 	test_ctime_is_atime -1
 '
 
-test_expect_success '--committer-date-is-author-date works with merge backend' '
+test_expect_failure '--committer-date-is-author-date works with merge backend' '
 	GIT_AUTHOR_DATE="@1234 +0300" git commit --amend --reset-author &&
 	git rebase -m --committer-date-is-author-date HEAD^ &&
 	test_ctime_is_atime -1
 '
 
-test_expect_success '--committer-date-is-author-date works with rebase -r' '
+test_expect_failure '--committer-date-is-author-date works with rebase -r' '
 	git checkout side &&
 	GIT_AUTHOR_DATE="@1234 +0300" git merge --no-ff commit3 &&
 	git rebase -r --root --committer-date-is-author-date &&
 	test_ctime_is_atime
 '
 
-test_expect_success '--committer-date-is-author-date works when forking merge' '
+test_expect_failure '--committer-date-is-author-date works when forking merge' '
 	git checkout side &&
 	GIT_AUTHOR_DATE="@1234 +0300" git merge --no-ff commit3 &&
 	PATH="./test-bin:$PATH" git rebase -r --root --strategy=test \
@@ -145,7 +145,7 @@  test_expect_success '--reset-author-date works with rebase -r' '
 	test_atime_is_ignored
 '
 
-test_expect_success '--reset-author-date with --committer-date-is-author-date works' '
+test_expect_failure '--reset-author-date with --committer-date-is-author-date works' '
 	test_must_fail git rebase -m --committer-date-is-author-date \
 		--reset-author-date --onto commit2^^ commit2^ commit3 &&
 	git checkout --theirs foo &&