File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -116,8 +116,13 @@ TESTS = tests/newline1/run-test \
116116 tests/combine2/run-test \
117117 tests/combine3/run-test \
118118 tests/combine4/run-test \
119+ tests/combine5/run-test \
120+ tests/combine6/run-test \
119121 tests/combine-devnull/run-test \
120122 tests/combine-devnull-p/run-test \
123+ tests/combine-no-match/run-test \
124+ tests/interdiff-devnull/run-test \
125+ tests/flipdiff-devnull/run-test \
121126 tests/gendiff1/run-test \
122127 tests/gendiff2/run-test \
123128 tests/comma/run-test \
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ # Test combinediff when no files match at any -p level
4+ # Should fall back to showing separate patches
5+
6+ . ${top_srcdir-.} /tests/common.sh
7+
8+ # Create first patch with one file
9+ cat << EOF > patch1
10+ --- /dev/null
11+ +++ b/file1.txt
12+ @@ -0,0 +1,2 @@
13+ +content1
14+ +line2
15+ EOF
16+
17+ # Create second patch with completely different file
18+ cat << EOF > patch2
19+ --- a/completely/different/file2.txt
20+ +++ b/completely/different/file2.txt
21+ @@ -1,1 +1,2 @@
22+ existing
23+ +new line
24+ EOF
25+
26+ # Run combinediff - should show separate patches since no files match
27+ ${COMBINEDIFF} patch1 patch2 2> errors > actual || exit 1
28+ [ -s errors ] && exit 1
29+
30+ # Should show "only in patch2:" indicating patches weren't combined
31+ grep -q " only in patch2:" actual || exit 1
32+
33+ # Should contain both patches
34+ grep -q " file1.txt" actual || exit 1
35+ grep -q " file2.txt" actual || exit 1
36+
37+ exit 0
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ # Test combinediff with file deletion (regular file to /dev/null)
4+ # This tests /dev/null handling in the reverse direction
5+
6+ . ${top_srcdir-.} /tests/common.sh
7+
8+ # Create first patch that creates a file
9+ cat << EOF > patch1
10+ --- /dev/null
11+ +++ b/tempfile.txt
12+ @@ -0,0 +1,3 @@
13+ +temporary
14+ +content
15+ +here
16+ EOF
17+
18+ # Create second patch that deletes the same file
19+ cat << EOF > patch2
20+ --- a/tempfile.txt
21+ +++ /dev/null
22+ @@ -1,3 +0,0 @@
23+ -temporary
24+ -content
25+ -here
26+ EOF
27+
28+ # Run combinediff
29+ ${COMBINEDIFF} patch1 patch2 2> errors > actual || exit 1
30+ [ -s errors ] && exit 1
31+
32+ # Expected combined output should be empty (create then delete = no change)
33+ diff -u /dev/null actual || exit 1
34+
35+ exit 0
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ # Test flipdiff with /dev/null automatic -p detection
4+ # This tests that flipdiff can auto-detect -p values when dealing with /dev/null
5+
6+ . ${top_srcdir-.} /tests/common.sh
7+
8+ # Create first patch (creates a file)
9+ cat << EOF > patch1
10+ --- /dev/null
11+ +++ b/testfile.c
12+ @@ -0,0 +1,2 @@
13+ +#include <stdio.h>
14+ +int main() { return 0; }
15+ EOF
16+
17+ # Create second patch (modifies the same file)
18+ cat << EOF > patch2
19+ --- a/testfile.c
20+ +++ b/testfile.c
21+ @@ -1,2 +1,3 @@
22+ #include <stdio.h>
23+ +#include <stdlib.h>
24+ int main() { return 0; }
25+ EOF
26+
27+ # Expected flipdiff output (should auto-detect -p1)
28+ cat << EOF > expected
29+ --- a/testfile.c
30+ +++ b/testfile.c
31+ @@ -0,0 +1 @@
32+ +#include <stdlib.h>
33+
34+ === 8< === cut here === 8< ===
35+
36+ --- /dev/null
37+ +++ b/testfile.c
38+ @@ -1 +1,3 @@
39+ +#include <stdio.h>
40+ #include <stdlib.h>
41+ +int main() { return 0; }
42+ EOF
43+
44+ # Run flipdiff - should auto-detect -p1 and produce flipped patches
45+ ${FLIPDIFF} patch1 patch2 2> errors > actual || exit 1
46+ [ -s errors ] && exit 1
47+
48+ # Compare the actual output with expected
49+ diff -u expected actual || exit 1
50+
51+ exit 0
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ # Test interdiff with /dev/null automatic -p detection
4+ # This tests that interdiff can auto-detect -p values when dealing with /dev/null
5+
6+ . ${top_srcdir-.} /tests/common.sh
7+
8+ # Create first patch (creates a file with initial content)
9+ cat << EOF > patch1
10+ --- /dev/null
11+ +++ b/newfile.txt
12+ @@ -0,0 +1,3 @@
13+ +line one
14+ +line two
15+ +line three
16+ EOF
17+
18+ # Create second patch (creates the same file with different content)
19+ cat << EOF > patch2
20+ --- /dev/null
21+ +++ a/newfile.txt
22+ @@ -0,0 +1,4 @@
23+ +line one
24+ +inserted line
25+ +line two
26+ +line three
27+ EOF
28+
29+ # Expected interdiff output (should auto-detect -p1)
30+ # This shows what needs to change to go from patch1's result to patch2's result
31+ cat << EOF > expected
32+ diff -u b/newfile.txt a/newfile.txt
33+ --- b/newfile.txt
34+ +++ a/newfile.txt
35+ @@ -1,3 +1,4 @@
36+ line one
37+ +inserted line
38+ line two
39+ line three
40+ EOF
41+
42+ # Run interdiff
43+ ${INTERDIFF} patch1 patch2 2> errors > actual || exit 1
44+ [ -s errors ] && exit 1
45+
46+ # Compare the actual output with expected
47+ diff -u expected actual || exit 1
48+
49+ exit 0
You can’t perform that action at this time.
0 commit comments