2015-01-16 19:54:47 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (C) 2015 Kyle J. McKay
|
|
|
|
#
|
|
|
|
|
|
|
|
test_description='git apply test patches with whitespace expansion.'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success setup '
|
|
|
|
#
|
|
|
|
## create test-N, patchN.patch, expect-N files
|
|
|
|
#
|
|
|
|
|
|
|
|
# test 1
|
|
|
|
printf "\t%s\n" 1 2 3 4 5 6 >before &&
|
|
|
|
printf "\t%s\n" 1 2 3 >after &&
|
|
|
|
printf "%64s\n" a b c >>after &&
|
|
|
|
printf "\t%s\n" 4 5 6 >>after &&
|
2019-11-27 19:53:29 +00:00
|
|
|
test_expect_code 1 git diff --no-index before after >patch1.patch.raw &&
|
|
|
|
sed -e "s/before/test-1/" -e "s/after/test-1/" patch1.patch.raw >patch1.patch &&
|
2015-01-16 19:54:47 +00:00
|
|
|
printf "%64s\n" 1 2 3 4 5 6 >test-1 &&
|
|
|
|
printf "%64s\n" 1 2 3 a b c 4 5 6 >expect-1 &&
|
|
|
|
|
|
|
|
# test 2
|
|
|
|
printf "\t%s\n" a b c d e f >before &&
|
|
|
|
printf "\t%s\n" a b c >after &&
|
|
|
|
n=10 &&
|
|
|
|
x=1 &&
|
|
|
|
while test $x -lt $n
|
|
|
|
do
|
tests: fix broken &&-chains in compound statements
The top-level &&-chain checker built into t/test-lib.sh causes tests to
magically exit with code 117 if the &&-chain is broken. However, it has
the shortcoming that the magic does not work within `{...}` groups,
`(...)` subshells, `$(...)` substitutions, or within bodies of compound
statements, such as `if`, `for`, `while`, `case`, etc. `chainlint.sed`
partly fills in the gap by catching broken &&-chains in `(...)`
subshells, but bugs can still lurk behind broken &&-chains in the other
cases.
Fix broken &&-chains in compound statements in order to reduce the
number of possible lurking bugs.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-12-09 05:11:06 +00:00
|
|
|
printf "%63s%d\n" "" $x >>after &&
|
2021-12-09 05:11:13 +00:00
|
|
|
x=$(( $x + 1 )) || return 1
|
2015-01-16 19:54:47 +00:00
|
|
|
done &&
|
|
|
|
printf "\t%s\n" d e f >>after &&
|
2019-11-27 19:53:29 +00:00
|
|
|
test_expect_code 1 git diff --no-index before after >patch2.patch.raw &&
|
|
|
|
sed -e "s/before/test-2/" -e "s/after/test-2/" patch2.patch.raw >patch2.patch &&
|
2015-01-16 19:54:47 +00:00
|
|
|
printf "%64s\n" a b c d e f >test-2 &&
|
|
|
|
printf "%64s\n" a b c >expect-2 &&
|
|
|
|
x=1 &&
|
|
|
|
while test $x -lt $n
|
|
|
|
do
|
tests: fix broken &&-chains in compound statements
The top-level &&-chain checker built into t/test-lib.sh causes tests to
magically exit with code 117 if the &&-chain is broken. However, it has
the shortcoming that the magic does not work within `{...}` groups,
`(...)` subshells, `$(...)` substitutions, or within bodies of compound
statements, such as `if`, `for`, `while`, `case`, etc. `chainlint.sed`
partly fills in the gap by catching broken &&-chains in `(...)`
subshells, but bugs can still lurk behind broken &&-chains in the other
cases.
Fix broken &&-chains in compound statements in order to reduce the
number of possible lurking bugs.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-12-09 05:11:06 +00:00
|
|
|
printf "%63s%d\n" "" $x >>expect-2 &&
|
2021-12-09 05:11:13 +00:00
|
|
|
x=$(( $x + 1 )) || return 1
|
2015-01-16 19:54:47 +00:00
|
|
|
done &&
|
|
|
|
printf "%64s\n" d e f >>expect-2 &&
|
|
|
|
|
|
|
|
# test 3
|
|
|
|
printf "\t%s\n" a b c d e f >before &&
|
|
|
|
printf "\t%s\n" a b c >after &&
|
|
|
|
n=100 &&
|
|
|
|
x=0 &&
|
|
|
|
while test $x -lt $n
|
|
|
|
do
|
tests: fix broken &&-chains in compound statements
The top-level &&-chain checker built into t/test-lib.sh causes tests to
magically exit with code 117 if the &&-chain is broken. However, it has
the shortcoming that the magic does not work within `{...}` groups,
`(...)` subshells, `$(...)` substitutions, or within bodies of compound
statements, such as `if`, `for`, `while`, `case`, etc. `chainlint.sed`
partly fills in the gap by catching broken &&-chains in `(...)`
subshells, but bugs can still lurk behind broken &&-chains in the other
cases.
Fix broken &&-chains in compound statements in order to reduce the
number of possible lurking bugs.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-12-09 05:11:06 +00:00
|
|
|
printf "%63s%02d\n" "" $x >>after &&
|
2021-12-09 05:11:13 +00:00
|
|
|
x=$(( $x + 1 )) || return 1
|
2015-01-16 19:54:47 +00:00
|
|
|
done &&
|
|
|
|
printf "\t%s\n" d e f >>after &&
|
2019-11-27 19:53:29 +00:00
|
|
|
test_expect_code 1 git diff --no-index before after >patch3.patch.raw &&
|
|
|
|
sed -e "s/before/test-3/" -e "s/after/test-3/" patch3.patch.raw >patch3.patch &&
|
2015-01-16 19:54:47 +00:00
|
|
|
printf "%64s\n" a b c d e f >test-3 &&
|
|
|
|
printf "%64s\n" a b c >expect-3 &&
|
|
|
|
x=0 &&
|
|
|
|
while test $x -lt $n
|
|
|
|
do
|
tests: fix broken &&-chains in compound statements
The top-level &&-chain checker built into t/test-lib.sh causes tests to
magically exit with code 117 if the &&-chain is broken. However, it has
the shortcoming that the magic does not work within `{...}` groups,
`(...)` subshells, `$(...)` substitutions, or within bodies of compound
statements, such as `if`, `for`, `while`, `case`, etc. `chainlint.sed`
partly fills in the gap by catching broken &&-chains in `(...)`
subshells, but bugs can still lurk behind broken &&-chains in the other
cases.
Fix broken &&-chains in compound statements in order to reduce the
number of possible lurking bugs.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-12-09 05:11:06 +00:00
|
|
|
printf "%63s%02d\n" "" $x >>expect-3 &&
|
2021-12-09 05:11:13 +00:00
|
|
|
x=$(( $x + 1 )) || return 1
|
2015-01-16 19:54:47 +00:00
|
|
|
done &&
|
|
|
|
printf "%64s\n" d e f >>expect-3 &&
|
|
|
|
|
|
|
|
# test 4
|
|
|
|
>before &&
|
|
|
|
x=0 &&
|
|
|
|
while test $x -lt 50
|
|
|
|
do
|
tests: fix broken &&-chains in compound statements
The top-level &&-chain checker built into t/test-lib.sh causes tests to
magically exit with code 117 if the &&-chain is broken. However, it has
the shortcoming that the magic does not work within `{...}` groups,
`(...)` subshells, `$(...)` substitutions, or within bodies of compound
statements, such as `if`, `for`, `while`, `case`, etc. `chainlint.sed`
partly fills in the gap by catching broken &&-chains in `(...)`
subshells, but bugs can still lurk behind broken &&-chains in the other
cases.
Fix broken &&-chains in compound statements in order to reduce the
number of possible lurking bugs.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-12-09 05:11:06 +00:00
|
|
|
printf "\t%02d\n" $x >>before &&
|
2021-12-09 05:11:13 +00:00
|
|
|
x=$(( $x + 1 )) || return 1
|
2015-01-16 19:54:47 +00:00
|
|
|
done &&
|
|
|
|
cat before >after &&
|
|
|
|
printf "%64s\n" a b c >>after &&
|
|
|
|
while test $x -lt 100
|
|
|
|
do
|
tests: fix broken &&-chains in compound statements
The top-level &&-chain checker built into t/test-lib.sh causes tests to
magically exit with code 117 if the &&-chain is broken. However, it has
the shortcoming that the magic does not work within `{...}` groups,
`(...)` subshells, `$(...)` substitutions, or within bodies of compound
statements, such as `if`, `for`, `while`, `case`, etc. `chainlint.sed`
partly fills in the gap by catching broken &&-chains in `(...)`
subshells, but bugs can still lurk behind broken &&-chains in the other
cases.
Fix broken &&-chains in compound statements in order to reduce the
number of possible lurking bugs.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-12-09 05:11:06 +00:00
|
|
|
printf "\t%02d\n" $x >>before &&
|
|
|
|
printf "\t%02d\n" $x >>after &&
|
2021-12-09 05:11:13 +00:00
|
|
|
x=$(( $x + 1 )) || return 1
|
2015-01-16 19:54:47 +00:00
|
|
|
done &&
|
2019-11-27 19:53:29 +00:00
|
|
|
test_expect_code 1 git diff --no-index before after >patch4.patch.raw &&
|
|
|
|
sed -e "s/before/test-4/" -e "s/after/test-4/" patch4.patch.raw >patch4.patch &&
|
2015-01-16 19:54:47 +00:00
|
|
|
>test-4 &&
|
|
|
|
x=0 &&
|
|
|
|
while test $x -lt 50
|
|
|
|
do
|
tests: fix broken &&-chains in compound statements
The top-level &&-chain checker built into t/test-lib.sh causes tests to
magically exit with code 117 if the &&-chain is broken. However, it has
the shortcoming that the magic does not work within `{...}` groups,
`(...)` subshells, `$(...)` substitutions, or within bodies of compound
statements, such as `if`, `for`, `while`, `case`, etc. `chainlint.sed`
partly fills in the gap by catching broken &&-chains in `(...)`
subshells, but bugs can still lurk behind broken &&-chains in the other
cases.
Fix broken &&-chains in compound statements in order to reduce the
number of possible lurking bugs.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-12-09 05:11:06 +00:00
|
|
|
printf "%63s%02d\n" "" $x >>test-4 &&
|
2021-12-09 05:11:13 +00:00
|
|
|
x=$(( $x + 1 )) || return 1
|
2015-01-16 19:54:47 +00:00
|
|
|
done &&
|
|
|
|
cat test-4 >expect-4 &&
|
|
|
|
printf "%64s\n" a b c >>expect-4 &&
|
|
|
|
while test $x -lt 100
|
|
|
|
do
|
tests: fix broken &&-chains in compound statements
The top-level &&-chain checker built into t/test-lib.sh causes tests to
magically exit with code 117 if the &&-chain is broken. However, it has
the shortcoming that the magic does not work within `{...}` groups,
`(...)` subshells, `$(...)` substitutions, or within bodies of compound
statements, such as `if`, `for`, `while`, `case`, etc. `chainlint.sed`
partly fills in the gap by catching broken &&-chains in `(...)`
subshells, but bugs can still lurk behind broken &&-chains in the other
cases.
Fix broken &&-chains in compound statements in order to reduce the
number of possible lurking bugs.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-12-09 05:11:06 +00:00
|
|
|
printf "%63s%02d\n" "" $x >>test-4 &&
|
|
|
|
printf "%63s%02d\n" "" $x >>expect-4 &&
|
2021-12-09 05:11:13 +00:00
|
|
|
x=$(( $x + 1 )) || return 1
|
2015-01-16 19:54:47 +00:00
|
|
|
done &&
|
|
|
|
|
|
|
|
git config core.whitespace tab-in-indent,tabwidth=63 &&
|
|
|
|
git config apply.whitespace fix
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
# Note that `patch` can successfully apply all patches when run
|
|
|
|
# with the --ignore-whitespace option.
|
|
|
|
|
|
|
|
for t in 1 2 3 4
|
|
|
|
do
|
|
|
|
test_expect_success 'apply with ws expansion (t=$t)' '
|
|
|
|
git apply patch$t.patch &&
|
2018-10-05 21:54:04 +00:00
|
|
|
test_cmp expect-$t test-$t
|
2015-01-16 19:54:47 +00:00
|
|
|
'
|
|
|
|
done
|
|
|
|
|
|
|
|
test_done
|