8000 git_merge_file_from_index: handle cases when a child (ours or theirs) is null by eantoranz · Pull Request #7092 · libgit2/libgit2 · GitHub
[go: up one dir, main page]

Skip to content

git_merge_file_from_index: handle cases when a child (ours or theirs) is null #7092

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
merge.h - improve handling when there is no ancestor in merge_file__b…
…est_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.
  • Loading branch information
eantoranz committed Jun 14, 2025
commit ba62ad349799812eaeaa73a3415bd6186b0709be
4 changes: 4 additions & 0 deletions src/libgit2/merge.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
0