Debian Codegraph @

tests/combine-devnull-p/run-test

raw
1 #!/bin/sh
2
3 # This is a combinediff(1) testcase for the /dev/null issue with explicit -p parameter.
4 # When -p is explicitly specified, it should use the traditional logic.
5
6 . ${top_srcdir-.}/tests/common.sh
7
8 # Create patches with same structure but different paths
9 cat << EOF > patch1
10 --- /dev/null
11 +++ path1/file.txt
12 @@ -0,0 +1,3 @@
13 +a
14 +b
15 +c
16 EOF
17
18 cat << EOF > patch2
19 --- path2/file.txt
20 +++ path1/file.txt
21 @@ -1,3 +1,2 @@
22 a
23 b
24 -c
25 EOF
26
27 # With -p0, these should NOT match (path1/file.txt vs path2/file.txt)
28 ${COMBINEDIFF} -p0 patch1 patch2 2>errors >actual || exit 1
29 [ -s errors ] && exit 1
30
31 # Should show separate patches
32 grep -q "only in patch2:" actual || exit 1
33
34 # With -p1, these SHOULD match (file.txt vs file.txt)
35 ${COMBINEDIFF} -p1 patch1 patch2 2>errors >actual || exit 1
36 [ -s errors ] && exit 1
37
38 # Should show combined patch
39 grep -q "only in patch2:" actual && exit 1
40
41 # Verify the combined result is correct
42 cat << EOF > expected
43 diff -u /dev/null path1/file.txt
44 --- /dev/null
45 +++ path1/file.txt
46 @@ -0,0 +1,2 @@
47 +a
48 +b
49 EOF
50
51 diff -u expected actual || exit 1
52
53 exit 0