#!/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