6c1aee8
commit b5a91a01e5d0897facdd0f49d64b76b0f02b43e1
6c1aee8
Author: Andreas Gruenbacher <agruen@gnu.org>
6c1aee8
Date:   Fri Apr 6 11:34:51 2018 +0200
6c1aee8
6c1aee8
    Allow input files to be missing for ed-style patches
6c1aee8
    
6c1aee8
    * src/pch.c (do_ed_script): Allow input files to be missing so that new
6c1aee8
    files will be created as with non-ed-style patches.
6c1aee8
6c1aee8
diff --git a/src/pch.c b/src/pch.c
6c1aee8
index bc6278c..0c5cc26 100644
6c1aee8
--- a/src/pch.c
6c1aee8
+++ b/src/pch.c
6c1aee8
@@ -2394,9 +2394,11 @@ do_ed_script (char const *inname, char const *outname,
6c1aee8
 
6c1aee8
     if (! dry_run && ! skip_rest_of_patch) {
6c1aee8
 	int exclusive = *outname_needs_removal ? 0 : O_EXCL;
6c1aee8
-	assert (! inerrno);
6c1aee8
-	*outname_needs_removal = true;
6c1aee8
-	copy_file (inname, outname, 0, exclusive, instat.st_mode, true);
6c1aee8
+	if (inerrno != ENOENT)
6c1aee8
+	  {
6c1aee8
+	    *outname_needs_removal = true;
6c1aee8
+	    copy_file (inname, outname, 0, exclusive, instat.st_mode, true);
6c1aee8
+	  }
6c1aee8
 	sprintf (buf, "%s %s%s", editor_program,
6c1aee8
 		 verbosity == VERBOSE ? "" : "- ",
6c1aee8
 		 outname);