Commit Diff


commit - fe66becbbe242300f7a2a5b9233dac96584839f004b922e11e6697ce705ed37f
commit + dab6752493ea36467c9018db975ebc9f64188cd3dd64e497ccfb0c2460db4358
blob - 48b6144db3cdd955b186ad1fbb12058d4e7e796733d64160033e889a8370aa46
blob + bb3286a455650fcd2cd8e7d3451e9c9bfe267504e76c5dd8addc71b9f4fa799c
--- regress/cmdline/patch.sh	
+++ regress/cmdline/patch.sh	
@@ -151,6 +151,75 @@ EOF
 	test_done $testroot $ret
 }
 
+test_patch_filename_with_whitespaces() {
+	local testroot=`test_init patch_filename_with_whitespaces`
+
+	got checkout $testroot/repo $testroot/wt >/dev/null
+	ret=$?
+	if [ $ret -ne 0 ]; then
+		test_done $testroot $ret
+		return 1
+	fi
+
+	# add a file with a whitespace in its name
+	cat <<EOF > $testroot/wt/patch
+--- /dev/null
++++ iota file$(printf '\t')
+@@ -0,0 +1 @@
++iota is my favourite character
+EOF
+
+	(cd $testroot/wt && got patch < patch) > $testroot/stdout
+	if [ $ret -ne 0 ]; then
+		test_done "$testroot" $ret
+		return 1
+	fi
+
+	echo 'A  iota file' > $testroot/stdout.expected
+	cmp -s $testroot/stdout.expected $testroot/stdout
+	ret=$?
+	if [ $ret -ne 0 ]; then
+		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done $testroot $ret
+		return 1
+	fi
+
+	echo 'iota is my favourite character' > $testroot/wt/iota.expected
+	cmp -s $testroot/wt/iota.expected $testroot/wt/'iota file'
+	ret=$?
+	if [ $ret -ne 0 ]; then
+		diff -u $testroot/wt/iota.expected $testroot/wt/iota
+		test_done "$testroot" $ret
+		return 1
+	fi
+
+	# now change it
+	cat <<EOF > $testroot/wt/patch
+--- iota file$(printf '\t')
++++ iota file$(printf '\t')
+@@ -1 +1 @@
+-iota is my favourite character
++iota is no longer my favourite character
+EOF
+
+	(cd $testroot/wt && got patch < patch) > $testroot/stdout
+	if [ $ret -ne 0 ]; then
+		test_done "$testroot" $ret
+		return 1
+	fi
+
+	echo 'M  iota file' > $testroot/stdout.expected
+	cmp -s $testroot/stdout.expected $testroot/stdout
+	ret=$?
+	if [ $ret -ne 0 ]; then
+		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done $testroot $ret
+		return 1
+	fi
+
+	test_done $testroot $ret
+}
+
 test_patch_dont_apply() {
 	local testroot=`test_init patch_dont_apply`
 
@@ -2149,6 +2218,7 @@ test_patch_commit_keywords() {
 
 test_parseargs "$@"
 run_test test_patch_basic
+run_test test_patch_filename_with_whitespaces
 run_test test_patch_dont_apply
 run_test test_patch_malformed
 run_test test_patch_no_patch