Commit dddfff77a49c5cf83d01ec66b09acbf80ef33a13

Edward Thomson 2018-06-30T17:12:16

apply: convert checkout conflicts to apply failures When there's a checkout conflict during apply, that means that the working directory was modified in a conflicting manner and the postimage cannot be written. During application, convert this to an application failure for consistency across workdir/index/both applications.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/src/apply.c b/src/apply.c
index fd1d533..1a20278 100644
--- a/src/apply.c
+++ b/src/apply.c
@@ -539,6 +539,13 @@ static int git_apply__to_workdir(
 
 	error = git_checkout_index(repo, postimage, &checkout_opts);
 
+	/*
+	 * When there's a checkout conflict, the file in the working directory
+	 * has been modified.  Upgrade this error to an application error.
+	 */
+	if (error == GIT_ECONFLICT)
+		error = GIT_EAPPLYFAIL;
+
 done:
 	git_vector_free(&paths);
 	return error;