#!/bin/sh # Test flipdiff with /dev/null automatic -p detection # This tests that flipdiff can auto-detect -p values when dealing with /dev/null . ${top_srcdir-.}/tests/common.sh # Create first patch (creates a file) cat << EOF > patch1 --- /dev/null +++ b/testfile.c @@ -0,0 +1,2 @@ +#include +int main() { return 0; } EOF # Create second patch (modifies the same file) cat << EOF > patch2 --- a/testfile.c +++ b/testfile.c @@ -1,2 +1,3 @@ #include +#include int main() { return 0; } EOF # Expected flipdiff output (should auto-detect -p1) cat << EOF > expected --- a/testfile.c +++ b/testfile.c @@ -0,0 +1 @@ +#include === 8< === cut here === 8< === --- /dev/null +++ b/testfile.c @@ -1 +1,3 @@ +#include #include +int main() { return 0; } EOF # Run flipdiff - should auto-detect -p1 and produce flipped patches ${FLIPDIFF} patch1 patch2 2>errors >actual || exit 1 [ -s errors ] && exit 1 # Compare the actual output with expected diff -u expected actual || exit 1 exit 0