about summary refs log tree commit diff
path: root/third_party/git/t/t4124-apply-ws-rule.sh
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/git/t/t4124-apply-ws-rule.sh')
-rwxr-xr-xthird_party/git/t/t4124-apply-ws-rule.sh17
1 files changed, 15 insertions, 2 deletions
diff --git a/third_party/git/t/t4124-apply-ws-rule.sh b/third_party/git/t/t4124-apply-ws-rule.sh
index ff51e9e78914..0ca29821ece3 100755
--- a/third_party/git/t/t4124-apply-ws-rule.sh
+++ b/third_party/git/t/t4124-apply-ws-rule.sh
@@ -35,9 +35,15 @@ prepare_test_file () {
 }
 
 apply_patch () {
+	cmd_prefix= &&
+	if test "x$1" = 'x!'
+	then
+		cmd_prefix=test_must_fail &&
+		shift
+	fi &&
 	>target &&
 	sed -e "s|\([ab]\)/file|\1/target|" <patch |
-	git apply "$@"
+	$cmd_prefix git apply "$@"
 }
 
 test_fix () {
@@ -46,6 +52,13 @@ test_fix () {
 
 	# find touched lines
 	$DIFF file target | sed -n -e "s/^> //p" >fixed
+	# busybox's diff(1) doesn't output normal format
+	if ! test -s fixed
+	then
+		$DIFF -u file target |
+		grep -v '^+++ target' |
+		sed -ne "/^+/s/+//p" >fixed
+	fi
 
 	# the changed lines are all expected to change
 	fixed_cnt=$(wc -l <fixed)
@@ -99,7 +112,7 @@ test_expect_success 'whitespace=warn, default rule' '
 
 test_expect_success 'whitespace=error-all, default rule' '
 
-	test_must_fail apply_patch --whitespace=error-all &&
+	apply_patch ! --whitespace=error-all &&
 	test_must_be_empty target
 
 '