Commit 7a3ab14f by Edward Thomson

merge driver: get a pointer to favor

parent 46625836
...@@ -918,7 +918,7 @@ static int merge_conflict_resolve_contents( ...@@ -918,7 +918,7 @@ static int merge_conflict_resolve_contents(
* favor flag) then let that override the gitattributes. * favor flag) then let that override the gitattributes.
*/ */
driver = &git_merge_driver__normal; driver = &git_merge_driver__normal;
data = (void *)file_opts->favor; data = (void **)&file_opts->favor;
} else { } else {
/* find the merge driver for this file */ /* find the merge driver for this file */
if ((error = git_merge_driver_for_source(&driver, &data, &source)) < 0) if ((error = git_merge_driver_for_source(&driver, &data, &source)) < 0)
......
...@@ -28,6 +28,9 @@ typedef struct { ...@@ -28,6 +28,9 @@ typedef struct {
static struct merge_driver_registry *merge_driver_registry = NULL; 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( static int merge_driver_apply(
git_merge_driver *self, git_merge_driver *self,
void **payload, void **payload,
...@@ -37,6 +40,7 @@ static int merge_driver_apply( ...@@ -37,6 +40,7 @@ static int merge_driver_apply(
const git_merge_driver_source *src) const git_merge_driver_source *src)
{ {
git_merge_file_options file_opts = GIT_MERGE_FILE_OPTIONS_INIT; 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}; git_merge_file_result result = {0};
int error; int error;
...@@ -45,7 +49,8 @@ static int merge_driver_apply( ...@@ -45,7 +49,8 @@ static int merge_driver_apply(
if (src->file_opts) if (src->file_opts)
memcpy(&file_opts, src->file_opts, sizeof(git_merge_file_options)); 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, if ((error = git_merge_file_from_index(&result, src->repo,
src->ancestor, src->ours, src->theirs, &file_opts)) < 0) src->ancestor, src->ours, src->theirs, &file_opts)) < 0)
...@@ -87,7 +92,7 @@ static int merge_driver_text_check( ...@@ -87,7 +92,7 @@ static int merge_driver_text_check(
GIT_UNUSED(name); GIT_UNUSED(name);
GIT_UNUSED(src); GIT_UNUSED(src);
*payload = (void *)GIT_MERGE_FILE_FAVOR_NORMAL; *payload = &merge_favor_normal;
return 0; return 0;
} }
...@@ -101,7 +106,7 @@ static int merge_driver_union_check( ...@@ -101,7 +106,7 @@ static int merge_driver_union_check(
GIT_UNUSED(name); GIT_UNUSED(name);
GIT_UNUSED(src); GIT_UNUSED(src);
*payload = (void *)GIT_MERGE_FILE_FAVOR_UNION; *payload = &merge_favor_union;
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment