1From b5a91a01e5d0897facdd0f49d64b76b0f02b43e1 Mon Sep 17 00:00:00 2001
2From: Andreas Gruenbacher <agruen@gnu.org>
3Date: Fri, 6 Apr 2018 11:34:51 +0200
4Subject: Allow input files to be missing for ed-style patches
5
6* src/pch.c (do_ed_script): Allow input files to be missing so that new
7files will be created as with non-ed-style patches.
8---
9 src/pch.c | 8 +++++---
10 1 file changed, 5 insertions(+), 3 deletions(-)
11
12diff --git a/src/pch.c b/src/pch.c
13index bc6278c..0c5cc26 100644
14--- a/src/pch.c
15+++ b/src/pch.c
16@@ -2394,9 +2394,11 @@ do_ed_script (char const *inname, char const *outname,
17
18     if (! dry_run && ! skip_rest_of_patch) {
19 	int exclusive = *outname_needs_removal ? 0 : O_EXCL;
20-	assert (! inerrno);
21-	*outname_needs_removal = true;
22-	copy_file (inname, outname, 0, exclusive, instat.st_mode, true);
23+	if (inerrno != ENOENT)
24+	  {
25+	    *outname_needs_removal = true;
26+	    copy_file (inname, outname, 0, exclusive, instat.st_mode, true);
27+	  }
28 	sprintf (buf, "%s %s%s", editor_program,
29 		 verbosity == VERBOSE ? "" : "- ",
30 		 outname);
31--
32cgit v1.0-41-gc330
33
34