git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH RFC] t0027: check the eol conversion warnings

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 20, 2014, 22:37 UTC
Message-ID
<xmqqr3wx1oth.fsf@gitster.dls.corp.google.com>
In-Reply-To
<546E5D26.8030109@web.de>
Torsten Bögershausen <tboegi@web.de> writes:
Show 7 quoted lines
> Add tests to check the warnings when adding file with eol=lf and eol=crlf.
>
> Add a function check_warning() to check the warnings on stderr
> "CRLF will be replaced..." or "LF will be replaced..."
>
> Signed-off-by: Torsten Bögershausen <tboegi@web.de>
> ---

At a glance it is very hard to see what we might be _losing_ with this change that claims to "add" new kinds of tests on top of existing ones.

I am guessing that add-check-warn roughly corresponds to the old create-file-in-repo but they have different calling conventions, or something?

Perhaps split it into two patches (or more), each of which does one thing and one thing well? I suspect that even with a two-patch split (e.g. the first of which only renames the function without adding the new "grep in error messages that could be localized and give false failures" code, and the second adds the lf/crlf stuff) might make this at least readable.

I dunno.
Show 164 quoted lines
>  t/t0027-auto-crlf.sh | 103 +++++++++++++++++++++++++++++++++++++++------------
>  1 file changed, 80 insertions(+), 23 deletions(-)
>
> diff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh
> index 2a4a6c1..9570947 100755
> --- a/t/t0027-auto-crlf.sh
> +++ b/t/t0027-auto-crlf.sh
> @@ -55,16 +55,36 @@ create_gitattributes () {
>  	esac
>  }
>  
> -create_file_in_repo () {
> +check_warning () {
> +	case "$1" in
> +	LF_CRLF) grep "LF will be replaced by CRLF" $2;;
> +	CRLF_LF) grep "CRLF will be replaced by LF" $2;;
> +	*) test_cmp /dev/null $2;;
> +	esac
> +}
> +
> +add_check_warn () {
>  	crlf=$1
>  	attr=$2
> +	lfname=$3
> +	crlfname=$4
> +	lfmixcrlf=$5
> +	lfmixcr=$6
> +	crlfnul=$7
>  	create_gitattributes "$attr" &&
> +	pfx=crlf_${crlf}_attr_${attr}
>  	for f in LF CRLF LF_mix_CR CRLF_mix_LF CRLF_nul
>  	do
> -		pfx=crlf_${crlf}_attr_${attr}_$f.txt &&
> -		cp $f $pfx && git -c core.autocrlf=$crlf add $pfx
> +		fname=${pfx}_$f.txt &&
> +		cp $f $fname &&
> +		git -c core.autocrlf=$crlf add $fname 2>"${pfx}_$f.err"
>  	done &&
> -	git commit -m "core.autocrlf $crlf"
> +	git commit -m "core.autocrlf $crlf" &&
> +	check_warning "$lfname" ${pfx}_LF.err &&
> +	check_warning "$crlfname" ${pfx}_CRLF.err &&
> +	check_warning "$lfmixcrlf" ${pfx}_LF_mix_CR.err &&
> +	check_warning "$lfmixcr" ${pfx}_LF_mix_CR.err &&
> +	check_warning "$crlfnul" ${pfx}_CRLF_nul.err
>  }
>  
>  check_files_in_repo () {
> @@ -140,50 +160,87 @@ test_expect_success 'setup master' '
>  '
>  
>  
> -test_expect_success 'create files' '
> -	create_file_in_repo false "" &&
> -	create_file_in_repo true  "" &&
> -	create_file_in_repo input "" &&
>  
> -	create_file_in_repo false "auto" &&
> -	create_file_in_repo true  "auto" &&
> -	create_file_in_repo input "auto" &&
> +warn_LF_CRLF="LF will be replaced by CRLF"
> +warn_CRLF_LF="CRLF will be replaced by LF"
> +
> +test_expect_success 'add files empty attr' '
> +	add_check_warn false ""     ""        ""        ""        ""        "" &&
> +	add_check_warn true  ""     "LF_CRLF" ""        ""        ""        "" &&
> +	add_check_warn input ""     ""        "CRLF_LF" ""        ""        ""
> +'
>  
> -	create_file_in_repo false "text" &&
> -	create_file_in_repo true  "text" &&
> -	create_file_in_repo input "text" &&
> +test_expect_success 'add files attr=auto' '
> +	add_check_warn false "auto" ""        "CRLF_LF" ""        ""        "" &&
> +	add_check_warn true  "auto" "LF_CRLF" ""        ""        ""        "" &&
> +	add_check_warn input "auto" ""        "CRLF_LF" ""        ""        ""
> +'
>  
> -	create_file_in_repo false "-text" &&
> -	create_file_in_repo true  "-text" &&
> -	create_file_in_repo input "-text" &&
> +test_expect_success 'add files attr=text' '
> +	add_check_warn false "text" ""        "CRLF_LF" ""        ""        "CRLF_LF" &&
> +	add_check_warn true  "text" "LF_CRLF" ""        "LF_CRLF" "LF_CRLF" ""        &&
> +	add_check_warn input "text" ""        "CRLF_LF" ""        ""        "CRLF_LF"
> +'
> +
> +test_expect_success 'add files attr=-text' '
> +	add_check_warn false "-text" ""       ""        ""        ""        "" &&
> +	add_check_warn true  "-text" ""       ""        ""        ""        "" &&
> +	add_check_warn input "-text" ""       ""        ""        ""        ""
> +'
> +
> +test_expect_success 'add files attr=lf' '
> +	add_check_warn false "lf"    ""       "CRLF_LF" ""         ""       "CRLF_LF" &&
> +	add_check_warn true  "lf"    ""       "CRLF_LF" ""         ""       "CRLF_LF" &&
> +	add_check_warn input "lf"    ""       "CRLF_LF" ""         ""       "CRLF_LF"
> +'
> +
> +test_expect_success 'add files attr=crlf' '
> +	add_check_warn false "crlf" "LF_CRLF" ""        "LF_CRLF" "LF_CRLF" "" &&
> +	add_check_warn true  "crlf" "LF_CRLF" ""        "LF_CRLF" "LF_CRLF" "" &&
> +	add_check_warn input "crlf" "LF_CRLF" ""        "LF_CRLF" "LF_CRLF" ""
> +'
> +
> +test_expect_success 'create files cleanup' '
>  	rm -f *.txt &&
>  	git reset --hard
>  '
>  
> -test_expect_success 'commit empty gitattribues' '
> +test_expect_success 'check file in repo empty gitattribues' '
>  	check_files_in_repo false ""      LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&
>  	check_files_in_repo true  ""      LF LF   LF          LF_mix_CR CRLF_nul &&
>  	check_files_in_repo input ""      LF LF   LF          LF_mix_CR CRLF_nul
>  '
>  
> -test_expect_success 'commit text=auto' '
> +test_expect_success 'check file in repo text=auto' '
>  	check_files_in_repo false "auto"  LF LF   LF          LF_mix_CR CRLF_nul &&
>  	check_files_in_repo true  "auto"  LF LF   LF          LF_mix_CR CRLF_nul &&
>  	check_files_in_repo input "auto"  LF LF   LF          LF_mix_CR CRLF_nul
>  '
>  
> -test_expect_success 'commit text' '
> +test_expect_success 'check file in repo text' '
>  	check_files_in_repo false "text"  LF LF   LF          LF_mix_CR LF_nul &&
>  	check_files_in_repo true  "text"  LF LF   LF          LF_mix_CR LF_nul &&
>  	check_files_in_repo input "text"  LF LF   LF          LF_mix_CR LF_nul
>  '
>  
> -test_expect_success 'commit -text' '
> +test_expect_success 'check file in repo -text' '
>  	check_files_in_repo false "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&
>  	check_files_in_repo true  "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&
>  	check_files_in_repo input "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
>  '
>  
> +test_expect_success 'check file in repo lf' '
> +	check_files_in_repo false "lf"    LF LF   LF          LF_mix_CR LF_nul &&
> +	check_files_in_repo true  "lf"    LF LF   LF          LF_mix_CR LF_nul &&
> +	check_files_in_repo input "lf"    LF LF   LF          LF_mix_CR LF_nul
> +'
> +
> +test_expect_success 'check file in repo crlf' '
> +	check_files_in_repo false "crlf"  LF LF   LF          LF_mix_CR LF_nul &&
> +	check_files_in_repo true  "crlf"  LF LF   LF          LF_mix_CR LF_nul &&
> +	check_files_in_repo input "crlf"  LF LF   LF          LF_mix_CR LF_nul
> +'
> +
>  ################################################################################
>  # Check how files in the repo are changed when they are checked out
>  # How to read the table below:
> @@ -199,8 +256,8 @@ test_expect_success 'commit -text' '
>  # - parameter $8 : reference for a file with CRLF and a NUL (should be handled as binary when auto)
>  
>  #                                            What we have in the repo:
> -#                														 ----------------- EOL in repo ----------------
> -#                														 LF    CRLF  CRLF_mix_LF  LF_mix_CR    CRLF_nul
> +#                                            ----------------- EOL in repo ----------------
> +#                                            LF    CRLF  CRLF_mix_LF  LF_mix_CR    CRLF_nul
>  #                   settings with checkout:
>  #                   core.   core.   .gitattr
>  #                    eol     acrlf
Previous: Torsten BögershausenNext: Torsten Bögershausen
Message 2 of 3 in “t0027: check the eol conversion warnings”
  1. t0027: check the eol conversion warningsTorsten Bögershausen, Nov 20, 2014
  2. Junio C HamanoNov 20, 2014
  3. Torsten BögershausenNov 21, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.