merge.h - improve handling when there is no ancestor in merge_file__best_path

In cases when a path is missing from the ancestor and only of the two
children is defined (IOW, the object is added), then the path in the child
that is defined should be returned.

However, merge_file__best_path is only returning a path in cases when there
is no ancestor path only if both children are defined and they match each
other.

Improve merge_file__best_path by handling the case when it is present in
only one of the children paths returning this value.
This commit is contained in:
Edmundo Carmona Antoranz
2025-06-14 00:02:03 +02:00
committed by Edward Thomson
parent 0bd182129f
commit b93afbc48f

View File

@@ -165,6 +165,10 @@ GIT_INLINE(const char *) git_merge_file__best_path(
if (!ancestor) {
if (ours && theirs && strcmp(ours, theirs) == 0)
return ours;
if (ours && !theirs)
return ours;
if (theirs && !ours)
return theirs;
return NULL;
}