Debian Codegraph @

tests/git-diff-duplication/run-test

raw
1 #!/bin/sh
2
3 # This is a filterdiff(1) testcase.
4 # Test: Bug where filterdiff duplicates "diff --git" lines
5 # When processing multiple git diff blocks where the second block has both
6 # rename and content changes, filterdiff incorrectly duplicates the second
7 # "diff --git" line. The output should be unchanged.
8
9 . ${top_srcdir-.}/tests/common.sh
10
11 # Create a minimal test case that triggers the duplication bug
12 cat << EOF > git-diff-bug.patch
13 diff --git a/file1 b/file2
14 similarity index 100%
15 rename from file1
16 rename to file2
17 diff --git a/file3 b/file4
18 similarity index 98%
19 rename from file3
20 rename to file4
21 index 1111111..2222222 100644
22 --- a/file3
23 +++ b/file4
24 @@ -1 +1 @@
25 -old
26 +new
27 EOF
28
29 # Test that filterdiff preserves the output unchanged
30 ${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip git-diff-bug.patch 2>errors >result || exit 1
31 [ -s errors ] && exit 1
32
33 # The result should be identical to the input
34 cmp git-diff-bug.patch result || exit 1
35
36 exit 0