mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-08 22:08:56 +00:00
graph: handle not finding a merge base gracefully
git_merge_base() returns GIT_ENOTFOUND when it cannot find a merge base. graph_desdendant_of() returns a boolean value (barring any errors), so it needs to catch the NOTFOUND return value and convert it into false, as not merge base means it cannot be a descendant.
This commit is contained in:
parent
2795fb4ddd
commit
ce2e82694a
@ -180,7 +180,12 @@ int git_graph_descendant_of(git_repository *repo, const git_oid *commit, const g
|
|||||||
if (git_oid_equal(commit, ancestor))
|
if (git_oid_equal(commit, ancestor))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if ((error = git_merge_base(&merge_base, repo, commit, ancestor)) < 0)
|
error = git_merge_base(&merge_base, repo, commit, ancestor);
|
||||||
|
/* No merge-base found, it's not a descendant */
|
||||||
|
if (error == GIT_ENOTFOUND)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (error < 0)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
return git_oid_equal(&merge_base, ancestor);
|
return git_oid_equal(&merge_base, ancestor);
|
||||||
|
Loading…
Reference in New Issue
Block a user