From: Thell Fowler Date: Sun, 23 Aug 2009 03:49:17 GMT Subject: [PATCH-v2/RFC 6/6] t4015: add tests for trailing-space on incomplete line Message-ID: <1250999357-10827-6-git-send-email-git@tbfowler.name> In-Reply-To: <1250999285-10683-1-git-send-email-git@tbfowler.name> - Add 7 --no-index tests to t4015-diff-whitespace.sh to check that ignore options work on incomplete lines. Signed-off-by: Thell Fowler --- t/t4015-diff-whitespace.sh | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-) diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh index 6d13da3..193ddbe 100755 --- a/t/t4015-diff-whitespace.sh +++ b/t/t4015-diff-whitespace.sh @@ -395,4 +395,37 @@ test_expect_success 'combined diff with autocrlf conversion' ' ' +# Ignore trailing-space testing on incomplete lines. +prepare_diff_file () { + printf "%s%$2s" foo "" >"$1" + if [ $3 = "+nl" ] + then + printf "\n" >>"$1" + fi +} + +diff_trailing () { + foo="foo___" + prepare_diff_file "left" "$2" "$3" + lfoo=$( expr substr $foo 1 $((3+$2)) ) + lfoo=${lfoo}"$3" + + prepare_diff_file "right" "$4" "$5" + rfoo=$( expr substr $foo 1 $((3+$4)) ) + rfoo=${rfoo}"$5" + + label="-$1 $lfoo $rfoo" + + test_expect_success "$label" \ + "! git diff --no-index -$1 -- left right | grep -q foo" +} + +diff_trailing w 0 +nl 1 -nl +diff_trailing w 0 -nl 1 -nl +diff_trailing b 0 +nl 0 -nl +diff_trailing b 1 +nl 0 -nl +diff_trailing b 1 -nl 0 -nl +diff_trailing -ignore-space-at-eol 0 +nl 0 -nl +diff_trailing -ignore-space-at-eol 2 +nl 2 -nl + test_done -- 1.6.4.176.g556a4