Commit 5b66b667e860212b4db3ed87fa735b4236b5ac7b

Edward Thomson 2018-06-29T12:39:41

apply: when preimage file is missing, return EAPPLYFAIL The preimage file being missing entirely is simply a case of an application failure; return the correct error value for the caller.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/src/apply.c b/src/apply.c
index 95c4fcb..fd1d533 100644
--- a/src/apply.c
+++ b/src/apply.c
@@ -409,8 +409,14 @@ static int apply_one(
 
 	if (delta->status != GIT_DELTA_ADDED) {
 		if ((error = git_reader_read(&pre_contents,
-		    preimage_reader, delta->old_file.path)) < 0)
+		    preimage_reader, delta->old_file.path)) < 0) {
+
+			/* ENOTFOUND is really an application error */
+			if (error == GIT_ENOTFOUND)
+				error = GIT_EAPPLYFAIL;
+
 			goto done;
+		}
 	}
 
 	if ((error = git_apply__patch(&post_contents, &filename, &mode,