summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@suse.de>2010-04-26 18:20:25 +0200
committerAndreas Gruenbacher <agruen@suse.de>2010-04-27 12:38:15 +0200
commitf558fff53365dd4fb315966f059160d3d2ece603 (patch)
tree83fb2980ff48548dac779a3d7f311ebaaff3534c
parent3aceaac3070bb4969e6bfd118061bc956385e288 (diff)
downloadpatch-f558fff53365dd4fb315966f059160d3d2ece603.tar.gz
Only check for reversed patches when the input file is patchable
* src/pch.c (intuit_diff_type): Only check for reversed patches when the input file is patchable in the first place.
-rw-r--r--ChangeLog3
-rw-r--r--src/pch.c4
2 files changed, 6 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index bd86fcc..fbde23e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2009-04-26 Andreas Gruenbacher <agruen@suse.de>
+ * src/pch.c (intuit_diff_type): Only check for reversed patches when
+ the input file is patchable in the first place.
+
* src/pch.c (get_input_file): If an input file is not a regular file,
only skip the patch instead of aborting.
* src/patch.c (main): If get_input_file() fails, skip the patch.
diff --git a/src/pch.c b/src/pch.c
index 0af1e15..47e4ee8 100644
--- a/src/pch.c
+++ b/src/pch.c
@@ -713,6 +713,7 @@ intuit_diff_type (bool need_header)
}
if (i0 != NONE
+ && (i == NONE || S_ISREG (st[i].st_mode))
&& maybe_reverse (p_name[i0], i == NONE,
i == NONE || st[i].st_size == 0))
i = i0;
@@ -747,7 +748,8 @@ intuit_diff_type (bool need_header)
if (inname)
{
inerrno = stat (inname, &instat) == 0 ? 0 : errno;
- maybe_reverse (inname, inerrno, inerrno || instat.st_size == 0);
+ if (inerrno || S_ISREG (instat.st_mode))
+ maybe_reverse (inname, inerrno, inerrno || instat.st_size == 0);
}
else
inerrno = -1;