diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-04-08 16:52:20 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-04-08 16:52:20 +0200 |
commit | ce2e82694a19b9994acaa9376bff81bc8e968637 (patch) | |
tree | 9cc64b5202f7711afc72da4e67d0ad0adbb8033e | |
parent | 2795fb4ddd69ca72828c2d4f1b94b77e4d91db48 (diff) | |
download | libgit2-ce2e82694a19b9994acaa9376bff81bc8e968637.tar.gz |
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.
-rw-r--r-- | src/graph.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/graph.c b/src/graph.c index 1c6441140..1c264d997 100644 --- a/src/graph.c +++ b/src/graph.c @@ -180,7 +180,12 @@ int git_graph_descendant_of(git_repository *repo, const git_oid *commit, const g if (git_oid_equal(commit, ancestor)) 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 git_oid_equal(&merge_base, ancestor); |