| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# Test combinediff with multiple path levels requiring -p2 |
| 4 |
# This tests the automatic detection of deeper path stripping |
| 5 |
|
| 6 |
. ${top_srcdir-.}/tests/common.sh |
| 7 |
|
| 8 |
# Create first patch with deeply nested path |
| 9 |
cat << EOF > patch1 |
| 10 |
--- /dev/null |
| 11 |
+++ b/src/deep/nested/file.c |
| 12 |
@@ -0,0 +1,2 @@ |
| 13 |
+#include <stdio.h> |
| 14 |
+int main() { return 0; } |
| 15 |
EOF |
| 16 |
|
| 17 |
# Create second patch modifying the same file with different path prefix |
| 18 |
cat << EOF > patch2 |
| 19 |
--- a/src/deep/nested/file.c |
| 20 |
+++ b/src/deep/nested/file.c |
| 21 |
@@ -1,2 +1,3 @@ |
| 22 |
#include <stdio.h> |
| 23 |
+#include <stdlib.h> |
| 24 |
int main() { return 0; } |
| 25 |
EOF |
| 26 |
|
| 27 |
# Expected combined output (should auto-detect -p1) |
| 28 |
cat << EOF > expected |
| 29 |
diff -u /dev/null b/src/deep/nested/file.c |
| 30 |
--- /dev/null |
| 31 |
+++ b/src/deep/nested/file.c |
| 32 |
@@ -0,0 +1,3 @@ |
| 33 |
+#include <stdio.h> |
| 34 |
+#include <stdlib.h> |
| 35 |
+int main() { return 0; } |
| 36 |
EOF |
| 37 |
|
| 38 |
# Run combinediff |
| 39 |
${COMBINEDIFF} patch1 patch2 2>errors >actual || exit 1 |
| 40 |
[ -s errors ] && exit 1 |
| 41 |
|
| 42 |
# Compare the actual output with expected |
| 43 |
diff -u expected actual || exit 1 |
| 44 |
|
| 45 |
exit 0 |