merge driver: get a pointer to favor
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
diff --git a/src/merge.c b/src/merge.c
index 5ef0f36..bf75cf2 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -918,7 +918,7 @@ static int merge_conflict_resolve_contents(
* favor flag) then let that override the gitattributes.
*/
driver = &git_merge_driver__normal;
- data = (void *)file_opts->favor;
+ data = (void **)&file_opts->favor;
} else {
/* find the merge driver for this file */
if ((error = git_merge_driver_for_source(&driver, &data, &source)) < 0)
diff --git a/src/merge_driver.c b/src/merge_driver.c
index 8795f2f..59b5461 100644
--- a/src/merge_driver.c
+++ b/src/merge_driver.c
@@ -28,6 +28,9 @@ typedef struct {
static struct merge_driver_registry *merge_driver_registry = NULL;
+static git_merge_file_favor_t merge_favor_normal = GIT_MERGE_FILE_FAVOR_NORMAL;
+static git_merge_file_favor_t merge_favor_union = GIT_MERGE_FILE_FAVOR_UNION;
+
static int merge_driver_apply(
git_merge_driver *self,
void **payload,
@@ -37,6 +40,7 @@ static int merge_driver_apply(
const git_merge_driver_source *src)
{
git_merge_file_options file_opts = GIT_MERGE_FILE_OPTIONS_INIT;
+ git_merge_file_favor_t *favor = (git_merge_file_favor_t *) *payload;
git_merge_file_result result = {0};
int error;
@@ -45,7 +49,8 @@ static int merge_driver_apply(
if (src->file_opts)
memcpy(&file_opts, src->file_opts, sizeof(git_merge_file_options));
- file_opts.favor = (git_merge_file_favor_t) *payload;
+ if (favor)
+ file_opts.favor = *favor;
if ((error = git_merge_file_from_index(&result, src->repo,
src->ancestor, src->ours, src->theirs, &file_opts)) < 0)
@@ -87,7 +92,7 @@ static int merge_driver_text_check(
GIT_UNUSED(name);
GIT_UNUSED(src);
- *payload = (void *)GIT_MERGE_FILE_FAVOR_NORMAL;
+ *payload = &merge_favor_normal;
return 0;
}
@@ -101,7 +106,7 @@ static int merge_driver_union_check(
GIT_UNUSED(name);
GIT_UNUSED(src);
- *payload = (void *)GIT_MERGE_FILE_FAVOR_UNION;
+ *payload = &merge_favor_union;
return 0;
}