git: 6613b91799ce - stable/14 - patch: test for unified diffs with spaces in filenames

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Sun, 12 Apr 2026 13:44:13 UTC
The branch stable/14 has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=6613b91799ce956c5a33ac9415f9bb700d1b5022

commit 6613b91799ce956c5a33ac9415f9bb700d1b5022
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2025-08-29 19:24:35 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2026-04-12 13:43:38 +0000

    patch: test for unified diffs with spaces in filenames
    
    The older GNU patch that we had in base did not properly handle spaces
    in filenames in unified diffs, but bsdpatch seems to have handled this
    fine at least since the version we imported into base initially.  Add a
    test with spaces in the filename specifically to be sure.
    
    PR:             181272
    (cherry picked from commit cc36624b2a8be3fbf180c5ae8d310d86486884bc)
---
 usr.bin/patch/tests/unified_patch_test.sh | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/usr.bin/patch/tests/unified_patch_test.sh b/usr.bin/patch/tests/unified_patch_test.sh
index 7d4b74182c41..a91332908773 100755
--- a/usr.bin/patch/tests/unified_patch_test.sh
+++ b/usr.bin/patch/tests/unified_patch_test.sh
@@ -141,6 +141,23 @@ file_removal_body()
 	atf_check -o inline:"y\n" cat foo
 }
 
+atf_test_case namespace
+namespace_head()
+{
+	atf_set "descr" "Test that patch(1) handles files with spaces in the name"
+}
+namespace_body()
+{
+	echo "ABC" > "with spaces.orig"
+	echo "ZYX" > "with spaces"
+
+	atf_check -s not-exit:0 -o save:spaces.diff \
+	    diff -u "with spaces.orig" "with spaces"
+
+	atf_check mv "with spaces.orig" "with spaces"
+	atf_check -o not-empty patch < spaces.diff
+}
+
 atf_test_case plinelen
 plinelen_body()
 {
@@ -166,5 +183,6 @@ atf_init_test_cases()
 	atf_add_test_case file_creation
 	atf_add_test_case file_nodupe
 	atf_add_test_case file_removal
+	atf_add_test_case namespace
 	atf_add_test_case plinelen
 }