1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
#!/bin/sh
# This is a combinediff(1) testcase for the /dev/null issue with explicit -p parameter.
# When -p is explicitly specified, it should use the traditional logic.
. ${top_srcdir-.}/tests/common.sh
# Create patches with same structure but different paths
cat << EOF > patch1
--- /dev/null
+++ path1/file.txt
@@ -0,0 +1,3 @@
+a
+b
+c
EOF
cat << EOF > patch2
--- path2/file.txt
+++ path1/file.txt
@@ -1,3 +1,2 @@
a
b
-c
EOF
# With -p0, these should NOT match (path1/file.txt vs path2/file.txt)
${COMBINEDIFF} -p0 patch1 patch2 2>errors >actual || exit 1
[ -s errors ] && exit 1
# Should show separate patches
grep -q "only in patch2:" actual || exit 1
# With -p1, these SHOULD match (file.txt vs file.txt)
${COMBINEDIFF} -p1 patch1 patch2 2>errors >actual || exit 1
[ -s errors ] && exit 1
# Should show combined patch
grep -q "only in patch2:" actual && exit 1
# Verify the combined result is correct
cat << EOF > expected
diff -u /dev/null path1/file.txt
--- /dev/null
+++ path1/file.txt
@@ -0,0 +1,2 @@
+a
+b
EOF
diff -u expected actual || exit 1
exit 0
|