mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-03 03:44:21 +00:00
merge drivers: handle configured but not found driver
This commit is contained in:
parent
6d8b2cdbee
commit
d953c4505e
17
src/merge.c
17
src/merge.c
@ -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) {
|
||||
if (error == GIT_PASSTHROUGH)
|
||||
fallback = true;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user