summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2018-09-29 19:32:51 +0100
committerEdward Thomson <ethomson@edwardthomson.com>2018-11-05 15:53:59 +0000
commit47cc5f85e9b95880e03cfa04d9708a643c587a13 (patch)
treeb475bd7e31ed7e8b56545cfaceb86c706054b95a /include/git2
parent398d8bfe606feddf8db738250fc1960887f53685 (diff)
downloadlibgit2-47cc5f85e9b95880e03cfa04d9708a643c587a13.tar.gz
apply: introduce a hunk callback
Introduce a callback to patch application that allows consumers to cancel hunk application.
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/apply.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/git2/apply.h b/include/git2/apply.h
index eb9cad4d1..7cc1c22a8 100644
--- a/include/git2/apply.h
+++ b/include/git2/apply.h
@@ -38,6 +38,22 @@ typedef int (*git_apply_delta_cb)(
void *payload);
/**
+ * When applying a patch, callback that will be made per hunk.
+ *
+ * When the callback:
+ * - returns < 0, the apply process will be aborted.
+ * - returns > 0, the hunk will not be applied, but the apply process
+ * continues
+ * - returns 0, the hunk is applied, and the apply process continues.
+ *
+ * @param hunk The hunk to be applied
+ * @param payload User-specified payload
+ */
+typedef int (*git_apply_hunk_cb)(
+ const git_diff_hunk *hunk,
+ void *payload);
+
+/**
* Apply options structure
*
* Initialize with `GIT_APPLY_OPTIONS_INIT`. Alternatively, you can
@@ -49,6 +65,7 @@ typedef struct {
unsigned int version;
git_apply_delta_cb delta_cb;
+ git_apply_hunk_cb hunk_cb;
void *payload;
} git_apply_options;