Skip to content

Commit 53f64b6

Browse files
committed
Merge pull request twaugh#5 from jpoimboe/interdiff-eof
Don't trim pre-context for patches at end of file
2 parents 5051d07 + a94095d commit 53f64b6

File tree

7 files changed

+23
-14
lines changed

7 files changed

+23
-14
lines changed

.gitignore

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,28 @@ src/rediff
2828

2929
# These are generated from *.in files
3030
/patchutils.spec
31-
/dehtmldiff
32-
/editdiff
33-
/espdiff
34-
/fixcvsdiff
35-
/recountdiff
36-
/splitdiff
37-
/unwrapdiff
31+
/scripts/dehtmldiff
32+
/scripts/editdiff
33+
/scripts/espdiff
34+
/scripts/fixcvsdiff
35+
/scripts/recountdiff
36+
/scripts/splitdiff
37+
/scripts/unwrapdiff
3838

3939
# These are generated from the XML file.
4040
doc/*.1
4141

42-
# Test arena
42+
# Tests
4343
/test-arena
44+
/test-driver
45+
/test-suite.log
46+
/tests/*/run-test.log
47+
/tests/*/run-test.trs
4448

4549
# Backup files
4650
*.bak
4751
*~
52+
*.swp
4853

4954
# Tarballs
5055
patchutils-*.tar.?z*

Makefile.am

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,7 @@ TESTS = tests/newline1/run-test \
222222
# Feel free to send me patches. :-)
223223
XFAIL_TESTS = \
224224
tests/delhunk5/run-test \
225-
tests/delhunk6/run-test \
226-
tests/trimlast1/run-test \
227-
tests/trimlast2/run-test
225+
tests/delhunk6/run-test
228226

229227
distclean-local:
230228
-rm -rf $(top_builddir)/test-arena

src/interdiff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ trim_context (FILE *f /* positioned at start of @@ line */,
933933

934934
pre -= strip_pre;
935935
post -= strip_post;
936-
if (pre > post)
936+
if (post && pre > post)
937937
strip_pre += pre - post;
938938
orig_offset += strip_pre;
939939
new_orig_count -= strip_pre + strip_post;

tests/flip2/run-test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ sed -e "s/$(/bin/echo -ne '\t').*$//" patch-flipped > patch-cmp
3333
cmp - patch-cmp << EOF || exit 1
3434
--- file.orig
3535
+++ file
36-
@@ -2,2 +2,2 @@
36+
@@ -1,3 +1,3 @@
37+
a
3738
-b
3839
c
3940
+d

tests/flip4/run-test

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ sed -e "s/$(/bin/echo -ne '\t').*$//" patch-flipped > patch-cmp
5757
cmp - patch-cmp << EOF || exit 1
5858
--- file.orig
5959
+++ file
60-
@@ -12 +11,0 @@
60+
@@ -9,4 +9,3 @@
61+
i
62+
j
63+
k
6164
-l
6265
6366
=== 8< === cut here === 8< ===

tests/trimlast1/run-test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ ${INTERDIFF} patch1 patch2 > patch1-2 2>errors || exit 1
4141
[ -s errors ] && exit 1
4242

4343
cat << EOF | cmp - patch1-2 || exit 1
44+
diff -u file file
4445
--- file
4546
+++ file
4647
@@ -6,3 +6,4 @@

tests/trimlast2/run-test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ ${COMBINEDIFF} patch1 patch2 > patch12 2>errors || exit 1
3535
[ -s errors ] && exit 1
3636

3737
cat << EOF | cmp - patch12 || exit 1
38+
diff -u file file
3839
--- file
3940
+++ file
4041
@@ -1,4 +1,4 @@

0 commit comments

Comments
 (0)