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
|
#!/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 <stdio.h>
+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 <stdio.h>
+#include <stdlib.h>
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 <stdlib.h>
=== 8< === cut here === 8< ===
--- /dev/null
+++ b/testfile.c
@@ -1 +1,3 @@
+#include <stdio.h>
#include <stdlib.h>
+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
|