1#!/bin/sh23test_description='diff whitespace error detection'45. ./test-lib.sh67test_expect_success setup '89git config diff.color.whitespace "blue reverse" &&10>F &&11git add F &&12echo " Eight SP indent" >>F &&13echo " HT and SP indent" >>F &&14echo "With trailing SP " >>F &&15echo "No problem" >>F1617'1819blue_grep='7;34m' ;# ESC [ 7 ; 3 4 m2021test_expect_success default '2223git diff --color >output24grep "$blue_grep" output >error25grep -v "$blue_grep" output >normal2627grep Eight normal >/dev/null &&28grep HT error >/dev/null &&29grep With error >/dev/null &&30grep No normal >/dev/null3132'3334test_expect_success 'without -trail' '3536git config core.whitespace -trail37git diff --color >output38grep "$blue_grep" output >error39grep -v "$blue_grep" output >normal4041grep Eight normal >/dev/null &&42grep HT error >/dev/null &&43grep With normal >/dev/null &&44grep No normal >/dev/null4546'4748test_expect_success 'without -trail (attribute)' '4950git config --unset core.whitespace51echo "F whitespace=-trail" >.gitattributes52git diff --color >output53grep "$blue_grep" output >error54grep -v "$blue_grep" output >normal5556grep Eight normal >/dev/null &&57grep HT error >/dev/null &&58grep With normal >/dev/null &&59grep No normal >/dev/null6061'6263test_expect_success 'without -space' '6465rm -f .gitattributes66git config core.whitespace -space67git diff --color >output68grep "$blue_grep" output >error69grep -v "$blue_grep" output >normal7071grep Eight normal >/dev/null &&72grep HT normal >/dev/null &&73grep With error >/dev/null &&74grep No normal >/dev/null7576'7778test_expect_success 'without -space (attribute)' '7980git config --unset core.whitespace81echo "F whitespace=-space" >.gitattributes82git diff --color >output83grep "$blue_grep" output >error84grep -v "$blue_grep" output >normal8586grep Eight normal >/dev/null &&87grep HT normal >/dev/null &&88grep With error >/dev/null &&89grep No normal >/dev/null9091'9293test_expect_success 'with indent-non-tab only' '9495rm -f .gitattributes96git config core.whitespace indent,-trailing,-space97git diff --color >output98grep "$blue_grep" output >error99grep -v "$blue_grep" output >normal100101grep Eight error >/dev/null &&102grep HT normal >/dev/null &&103grep With normal >/dev/null &&104grep No normal >/dev/null105106'107108test_expect_success 'with indent-non-tab only (attribute)' '109110git config --unset core.whitespace111echo "F whitespace=indent,-trailing,-space" >.gitattributes112git diff --color >output113grep "$blue_grep" output >error114grep -v "$blue_grep" output >normal115116grep Eight error >/dev/null &&117grep HT normal >/dev/null &&118grep With normal >/dev/null &&119grep No normal >/dev/null120121'122123test_done