diff options
author | Torsten Bögershausen <tboegi@web.de> | 2015-04-17 17:44:05 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-04-18 11:47:33 -0700 |
commit | d6d6673e66deb6c6263dbe3d6668748c4f51c9a6 (patch) | |
tree | 0344aaba421700ee9de9390770d5d51b606df08e /t/t0027-auto-crlf.sh | |
parent | ad295bbca2fb88e2056fd466817bbbf344c750f4 (diff) | |
download | git-d6d6673e66deb6c6263dbe3d6668748c4f51c9a6.tar.gz |
t0027: support NATIVE_CRLF platforms
t0027 expects the native end-of-lines to be a single line feed
character. On Windows, however, we set it to a carriage return
character followed by a line feed character. Thus, we have to
modify t0027 to expect different warnings depending on the
end-of-line markers.
Adjust the check of the warnings and use these macros:
WILC: Warn if LF becomes CRLF
WICL: Warn if CRLF becomes LF
WAMIX: Mixed line endings: either CRLF->LF or LF->CRLF
Improve the information given by check_warning().
Use test_cmp to show which warning is missing (or shouldn't be
there).
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t0027-auto-crlf.sh')
-rwxr-xr-x | t/t0027-auto-crlf.sh | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh index 585839729c..810934b9b7 100755 --- a/t/t0027-auto-crlf.sh +++ b/t/t0027-auto-crlf.sh @@ -57,15 +57,13 @@ create_gitattributes () { 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;; - '') - >expect - grep "will be replaced by" $2 >actual - test_cmp expect actual - ;; - *) false ;; + LF_CRLF) echo "warning: LF will be replaced by CRLF" >"$2".expect ;; + CRLF_LF) echo "warning: CRLF will be replaced by LF" >"$2".expect ;; + '') >"$2".expect ;; + *) echo >&2 "Illegal 1": "$1" ; return false ;; esac + grep "will be replaced by" "$2" | sed -e "s/\(.*\) in [^ ]*$/\1/" >"$2".actual + test_cmp "$2".expect "$2".actual } commit_check_warn () { @@ -169,6 +167,20 @@ test_expect_success 'setup master' ' warn_LF_CRLF="LF will be replaced by CRLF" warn_CRLF_LF="CRLF will be replaced by LF" +# WILC stands for "Warn if (this OS) converts LF into CRLF". +# WICL: Warn if CRLF becomes LF +# WAMIX: Mixed line endings: either CRLF->LF or LF->CRLF +if test_have_prereq NATIVE_CRLF +then + WILC=LF_CRLF + WICL= + WAMIX=LF_CRLF +else + WILC= + WICL=CRLF_LF + WAMIX=CRLF_LF +fi + test_expect_success 'commit files empty attr' ' commit_check_warn false "" "" "" "" "" "" && commit_check_warn true "" "LF_CRLF" "" "LF_CRLF" "" "" && @@ -176,13 +188,13 @@ test_expect_success 'commit files empty attr' ' ' test_expect_success 'commit files attr=auto' ' - commit_check_warn false "auto" "" "CRLF_LF" "CRLF_LF" "" "" && + commit_check_warn false "auto" "$WILC" "$WICL" "$WAMIX" "" "" && commit_check_warn true "auto" "LF_CRLF" "" "LF_CRLF" "" "" && commit_check_warn input "auto" "" "CRLF_LF" "CRLF_LF" "" "" ' test_expect_success 'commit files attr=text' ' - commit_check_warn false "text" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF" && + commit_check_warn false "text" "$WILC" "$WICL" "$WAMIX" "$WILC" "$WICL" && commit_check_warn true "text" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" && commit_check_warn input "text" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF" ' |