diff mbox series

[v4,2/2] log, show: add tests for messages containing CRLF

Message ID 75a87887be5d8364b37655f0588ed98a52de92bc.1603335680.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series [v3,1/3] t: add lib-crlf-messages.sh for messages containing CRLF | expand

Commit Message

Philippe Blain Oct. 22, 2020, 3:01 a.m. UTC
From: Philippe Blain <levraiphilippeblain@gmail.com>

A previous commit fixed a bug in ref-filter.c causing messages
containing CRLF to be incorrectly parsed and displayed.

Add tests to also check that `git log` and `git show` correctly handle
such messages, to prevent futur regressions if these commands are
refactored to use the ref-filter API.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
---
 t/t3920-crlf-messages.sh | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Philippe Blain Oct. 22, 2020, 7:24 p.m. UTC | #1
> Le 21 oct. 2020 à 23:01, Philippe Blain via GitGitGadget <gitgitgadget@gmail.com> a écrit :
> 
> From: Philippe Blain <levraiphilippeblain@gmail.com>
> 
> A previous commit fixed a bug in ref-filter.c causing messages
> containing CRLF to be incorrectly parsed and displayed.
> 
> Add tests to also check that `git log` and `git show` correctly handle
> such messages, to prevent futur regressions if these commands are
> refactored to use the ref-filter API.
> 
> Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
> ---
> t/t3920-crlf-messages.sh | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
> 
> diff --git a/t/t3920-crlf-messages.sh b/t/t3920-crlf-messages.sh
> index 3f0ce02c3f..b6e09be412 100755
> --- a/t/t3920-crlf-messages.sh
> +++ b/t/t3920-crlf-messages.sh
> @@ -105,4 +105,22 @@ test_crlf_subject_body_and_contents tag --list tag-crlf*
> 
> test_crlf_subject_body_and_contents for-each-ref refs/heads/crlf*
> 
> +test_expect_success 'log: --oneline works with messages using CRLF' '
> +	for branch in $LIB_CRLF_BRANCHES
> +	do
> +		cat .crlf-subject-${branch}.txt >expect &&
> +		printf "\n" >>expect &&
> +		git log --oneline -1 ${branch} >tmp-branch &&
> +		git log --oneline -1 tag-${branch} >tmp-tag &&
> +		cut -d" " -f2- <tmp-branch >actual-branch &&
> +		cut -d" " -f2- <tmp-tag >actual-tag &&
> +		test_cmp expect actual-branch &&
> +		test_cmp expect actual-tag
> +	done

I just realized that I'm missing this in this patch :

diff --git a/t/t3920-crlf-messages.sh b/t/t3920-crlf-messages.sh
index b6e09be412..70ddce3a2e 100755
--- a/t/t3920-crlf-messages.sh
+++ b/t/t3920-crlf-messages.sh
@@ -115,7 +115,7 @@ test_expect_success 'log: --oneline works with messages using CRLF' '
 		cut -d" " -f2- <tmp-branch >actual-branch &&
 		cut -d" " -f2- <tmp-tag >actual-tag &&
 		test_cmp expect actual-branch &&
-		test_cmp expect actual-tag
+		test_cmp expect actual-tag || return 1
 	done
 '

I'll wait a few days for any further comments and re-send with this tweak.

Philippe.
diff mbox series

Patch

diff --git a/t/t3920-crlf-messages.sh b/t/t3920-crlf-messages.sh
index 3f0ce02c3f..b6e09be412 100755
--- a/t/t3920-crlf-messages.sh
+++ b/t/t3920-crlf-messages.sh
@@ -105,4 +105,22 @@  test_crlf_subject_body_and_contents tag --list tag-crlf*
 
 test_crlf_subject_body_and_contents for-each-ref refs/heads/crlf*
 
+test_expect_success 'log: --oneline works with messages using CRLF' '
+	for branch in $LIB_CRLF_BRANCHES
+	do
+		cat .crlf-subject-${branch}.txt >expect &&
+		printf "\n" >>expect &&
+		git log --oneline -1 ${branch} >tmp-branch &&
+		git log --oneline -1 tag-${branch} >tmp-tag &&
+		cut -d" " -f2- <tmp-branch >actual-branch &&
+		cut -d" " -f2- <tmp-tag >actual-tag &&
+		test_cmp expect actual-branch &&
+		test_cmp expect actual-tag
+	done
+'
+
+test_crlf_subject_body_and_contents log --all --reverse --grep Subject
+
+test_crlf_subject_body_and_contents show $LIB_CRLF_BRANCHES
+
 test_done