6ae7ae0
diff -up patch-2.7.6/src/patch.c.git-style patch-2.7.6/src/patch.c
6ae7ae0
--- patch-2.7.6/src/patch.c.git-style	2018-02-03 13:41:49.000000000 +0100
6ae7ae0
+++ patch-2.7.6/src/patch.c	2018-10-11 15:01:08.709406802 +0200
6ae7ae0
@@ -1938,8 +1938,12 @@ output_files (struct stat const *st)
6ae7ae0
 {
6ae7ae0
   gl_list_iterator_t iter;
6ae7ae0
   const void *elt;
6ae7ae0
+  gl_list_t files;
6ae7ae0
 
6ae7ae0
-  iter = gl_list_iterator (files_to_output);
6ae7ae0
+  files = files_to_output;
6ae7ae0
+  init_files_to_output ();
6ae7ae0
+
6ae7ae0
+  iter = gl_list_iterator (files);
6ae7ae0
   while (gl_list_iterator_next (&iter, &elt, NULL))
6ae7ae0
     {
6ae7ae0
       const struct file_to_output *file_to_output = elt;
6ae7ae0
@@ -1957,8 +1961,8 @@ output_files (struct stat const *st)
6ae7ae0
 	  /* Free the list up to here. */
6ae7ae0
 	  for (;;)
6ae7ae0
 	    {
6ae7ae0
-	      const void *elt2 = gl_list_get_at (files_to_output, 0);
6ae7ae0
-	      gl_list_remove_at (files_to_output, 0);
6ae7ae0
+	      const void *elt2 = gl_list_get_at (files, 0);
6ae7ae0
+	      gl_list_remove_at (files, 0);
6ae7ae0
 	      if (elt == elt2)
6ae7ae0
 		break;
6ae7ae0
 	    }
6ae7ae0
@@ -1967,7 +1971,7 @@ output_files (struct stat const *st)
6ae7ae0
 	}
6ae7ae0
     }
6ae7ae0
   gl_list_iterator_free (&iter);
6ae7ae0
-  gl_list_clear (files_to_output);
6ae7ae0
+  gl_list_clear (files);
6ae7ae0
 }
6ae7ae0
 
6ae7ae0
 /* Fatal exit with cleanup. */
6ae7ae0
diff -up patch-2.7.6/tests/git-error.git-style patch-2.7.6/tests/git-error
6ae7ae0
--- patch-2.7.6/tests/git-error.git-style	2018-10-11 15:00:09.349200685 +0200
6ae7ae0
+++ patch-2.7.6/tests/git-error	2018-10-11 15:00:09.349200685 +0200
6ae7ae0
@@ -0,0 +1,29 @@
6ae7ae0
+# Copyright (C) 2018 Free Software Foundation, Inc.
6ae7ae0
+#
6ae7ae0
+# Copying and distribution of this file, with or without modification,
6ae7ae0
+# in any medium, are permitted without royalty provided the copyright
6ae7ae0
+# notice and this notice are preserved.
6ae7ae0
+
6ae7ae0
+. $srcdir/test-lib.sh
6ae7ae0
+
6ae7ae0
+require cat
6ae7ae0
+use_local_patch
6ae7ae0
+use_tmpdir
6ae7ae0
+
6ae7ae0
+cat > f.diff <
6ae7ae0
+diff --git a/boo b/boo
6ae7ae0
+--- /dev/fd/63 2018-02-27 16:32:54.861266246 +0100
6ae7ae0
++++ /dev/fd/62 2018-02-27 16:32:54.861266246 +0100
6ae7ae0
+@@ -1 +1 @@
6ae7ae0
+-abc
6ae7ae0
++def
6ae7ae0
+
6ae7ae0
+EOF
6ae7ae0
+
6ae7ae0
+check 'patch .nonexistent < f.diff || echo "Status: $?"' <
6ae7ae0
+patching file .nonexistent
6ae7ae0
+Hunk #1 FAILED at 1.
6ae7ae0
+1 out of 1 hunk FAILED -- saving rejects to file .nonexistent.rej
6ae7ae0
+$PATCH: **** Can't reopen file .nonexistent : No such file or directory
6ae7ae0
+Status: 2
6ae7ae0
+EOF