t4125-apply-ws-fuzz.sh [plain text]
#!/bin/sh
test_description='applying patch that has broken whitespaces in context'
. ./test-lib.sh
test_expect_success setup '
>file &&
git add file &&
for l in a bb c d eeee f ggg h
do
echo "$l "
done >file-0 &&
cat file-0 >file &&
git diff >patch-0 &&
git add file &&
sed -e "s/d/D/" file-0 >file-1 &&
cat file-1 >file &&
git diff >patch-1 &&
>file &&
git add file &&
cat file-1 >file &&
git diff >patch-all &&
sed -e "s/ \$//" patch-1 >patch-2 &&
sed -e "s/ \$//" file-1 >file-fixed
'
test_expect_success nofix '
>file &&
git add file &&
git apply --whitespace=nowarn patch-0 &&
git apply --whitespace=nowarn patch-1 &&
test_cmp file-1 file
'
test_expect_success 'withfix (forward)' '
>file &&
git add file &&
git apply --whitespace=fix patch-0 &&
git apply --whitespace=fix patch-1 &&
test_cmp file-fixed file
'
test_expect_success 'withfix (backward)' '
>file &&
git add file &&
git apply --whitespace=nowarn patch-0 &&
git apply --whitespace=fix patch-2 &&
sed -e /h/d file-fixed >fixed-head &&
sed -e /h/d file >file-head &&
test_cmp fixed-head file-head &&
sed -n -e /h/p file-fixed >fixed-tail &&
sed -n -e /h/p file >file-tail &&
! test_cmp fixed-tail file-tail
'
test_done