Commit d953c450 by Edward Thomson

merge drivers: handle configured but not found driver

parent 6d8b2cdb
......@@ -891,7 +891,8 @@ static int merge_conflict_resolve_contents(
git_index_entry *merge_result;
git_odb *odb = NULL;
const char *name;
int error = 0;
bool fallback = false;
int error;
assert(resolved && diff_list && conflict);
......@@ -924,12 +925,20 @@ static int merge_conflict_resolve_contents(
/* find the merge driver for this file */
if ((error = git_merge_driver_for_source(&name, &driver, &source)) < 0)
goto done;
if (driver == NULL)
fallback = true;
}
error = merge_conflict_invoke_driver(&merge_result, name, driver,
diff_list, &source);
if (driver) {
error = merge_conflict_invoke_driver(&merge_result, name, driver,
diff_list, &source);
if (error == GIT_PASSTHROUGH)
fallback = true;
}
if (error == GIT_PASSTHROUGH) {
if (fallback) {
error = merge_conflict_invoke_driver(&merge_result, "text",
&git_merge_driver__text.base, diff_list, &source);
}
......
......@@ -368,3 +368,21 @@ void test_merge_driver__unset_forces_binary(void)
cl_git_pass(git_index_conflict_get(&ancestor, &ours, &theirs,
repo_index, "automergeable.txt"));
}
void test_merge_driver__not_configured_driver_falls_back(void)
{
const git_index_entry *idx;
test_drivers_unregister();
/* `merge` without specifying a driver indicates `text` */
set_gitattributes_to("notfound");
merge_branch();
cl_assert((idx = git_index_get_bypath(repo_index, "automergeable.txt", 0)));
cl_assert_equal_oid(&automergeable_id, &idx->id);
test_drivers_register();
}
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