diff options
Diffstat (limited to 'src/patch.c')
-rw-r--r-- | src/patch.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/patch.c b/src/patch.c index 42d0267..a60e631 100644 --- a/src/patch.c +++ b/src/patch.c @@ -115,6 +115,7 @@ main (int argc, char **argv) struct stat tmpoutst; char numbuf[LINENUM_LENGTH_BOUND + 1]; bool written_to_rejname = false; + bool skip_reject_file = false; bool apply_empty_patch = false; mode_t file_type; int outfd = -1; @@ -190,6 +191,7 @@ main (int argc, char **argv) there_is_another_patch (! (inname || posixly_correct), &file_type) || apply_empty_patch; reinitialize_almost_everything(), + skip_reject_file = false, apply_empty_patch = false ) { /* for each patch in patch file */ int hunk = 0; @@ -310,8 +312,19 @@ main (int argc, char **argv) O_WRONLY | binary_transput, instat.st_mode & S_IRWXUGO); if (outfd == -1) - pfatal ("Can't create temporary file %s", TMPOUTNAME); - TMPOUTNAME_needs_removal = true; + { + if (errno == ELOOP || errno == EXDEV) + { + say ("Invalid file name %s -- skipping patch\n", quotearg (outname)); + skip_rest_of_patch = true; + skip_reject_file = true; + somefailed = true; + } + else + pfatal ("Can't create temporary file %s", TMPOUTNAME); + } + else + TMPOUTNAME_needs_removal = true; if (diff_type == ED_DIFF) { outstate.zero_output = false; somefailed |= skip_rest_of_patch; @@ -454,7 +467,8 @@ main (int argc, char **argv) || ! where || ! apply_hunk (&outstate, where)))) { - abort_hunk (outname, ! failed, reverse); + if (! skip_reject_file) + abort_hunk (outname, ! failed, reverse); failed++; if (verbosity == VERBOSE || (! skip_rest_of_patch && verbosity != SILENT)) @@ -595,7 +609,7 @@ main (int argc, char **argv) if (diff_type != ED_DIFF) { struct stat rejst; - if (failed) { + if (failed && ! skip_reject_file) { if (fstat (fileno (rejfp), &rejst) != 0 || fclose (rejfp) != 0) write_fatal (); rejfp = NULL; |