diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2018-06-25 21:24:49 +0900 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2018-11-04 09:21:48 +0000 |
commit | c3077ea0fa5ea8e0b27b1b47e95032da0591d861 (patch) | |
tree | 901b1d5ddd1476df31f4d56793ae163ab10a0a7f | |
parent | 973bf0c804c1431827fea9fde14ca4b3ca2fe995 (diff) | |
download | libgit2-c3077ea0fa5ea8e0b27b1b47e95032da0591d861.tar.gz |
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.
-rw-r--r-- | include/git2/errors.h | 1 | ||||
-rw-r--r-- | src/apply.c | 2 |
2 files changed, 2 insertions, 1 deletions
diff --git a/include/git2/errors.h b/include/git2/errors.h index c2a01de76..b0ce45fe5 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 20d755790..ad24e6c61 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. |