Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ TESTS = tests/newline1/run-test \
tests/whitespace-regression/run-test \
tests/interdiff-whitespace-w/run-test \
tests/patch-ignore-whitespace/run-test \
tests/whitespace-w/run-test
tests/whitespace-w/run-test \
tests/filterdiff-inplace1/run-test \
tests/rediff-inplace1/run-test

# These ones don't work yet.
# Feel free to send me patches. :-)
Expand Down
36 changes: 36 additions & 0 deletions tests/filterdiff-inplace1/run-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/sh

# This is a filterdiff(1) testcase.
# Test: --in-place option with --include filter

. ${top_srcdir-.}/tests/common.sh

cat << "EOF" > test.patch
--- a/file1.txt 2023-01-01 00:00:00.000000000 +0000
+++ b/file1.txt 2023-01-01 00:00:01.000000000 +0000
@@ -1,3 +1,3 @@
line 1
-line 2
+line 2 modified
line 3
--- a/file2.txt 2023-01-01 00:00:00.000000000 +0000
+++ b/file2.txt 2023-01-01 00:00:01.000000000 +0000
@@ -1,2 +1,2 @@
-old content
+new content
another line
EOF

# Test --in-place with --include
${FILTERDIFF} --include="*file1*" --in-place test.patch || exit 1

# Check that file was modified in place and contains only file1.txt
cmp - test.patch << "EOF" || exit 1
--- a/file1.txt 2023-01-01 00:00:00.000000000 +0000
+++ b/file1.txt 2023-01-01 00:00:01.000000000 +0000
@@ -1,3 +1,3 @@
line 1
-line 2
+line 2 modified
line 3
EOF
34 changes: 34 additions & 0 deletions tests/rediff-inplace1/run-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh

# This is a rediff(1) testcase.
# Test: --in-place option

. ${top_srcdir-.}/tests/common.sh

cat << "EOF" > patch.orig
--- file
+++ file
@@ -3,3 +3,4 @@
1
2
3
+4.5
EOF

cat << "EOF" > patch.mod
--- file
+++ file
@@ -3,3 +3,4 @@
+4.5
EOF

# Test --in-place
${REDIFF} --in-place patch.orig patch.mod || exit 1

# Check that patch.mod was modified in place
cmp - patch.mod << "EOF" || exit 1
--- file
+++ file
@@ -6,0 +6 @@
+4.5
EOF