apply: return a specific exit code on failure Return `GIT_EAPPLYFAIL` on patch application failure so that users can determine that patch application failed due to a malformed/conflicting patch by looking at the error code.
diff --git a/include/git2/errors.h b/include/git2/errors.h
index c2a01de..b0ce45f 100644
--- a/include/git2/errors.h
+++ b/include/git2/errors.h
@@ -57,6 +57,7 @@ typedef enum {
GIT_RETRY = -32, /**< Internal only */
GIT_EMISMATCH = -33, /**< Hashsum mismatch in object */
GIT_EINDEXDIRTY = -34, /**< Unsaved changes in the index would be overwritten */
+ GIT_EAPPLYFAIL = -35, /**< Patch application failed */
} git_error_code;
/**
diff --git a/src/apply.c b/src/apply.c
index 20d7557..ad24e6c 100644
--- a/src/apply.c
+++ b/src/apply.c
@@ -24,7 +24,7 @@
#include "reader.h"
#define apply_err(...) \
- ( giterr_set(GITERR_PATCH, __VA_ARGS__), -1 )
+ ( giterr_set(GITERR_PATCH, __VA_ARGS__), GIT_EAPPLYFAIL )
typedef struct {
/* The lines that we allocate ourself are allocated out of the pool.