aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/merge-base.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2024-02-28 09:44:09 +0000
committerJunio C Hamano <gitster@pobox.com>2024-02-28 09:47:03 -0800
commit24876ebf68baf90075dad5ca3acba8a305f308d4 (patch)
tree99968921866edefd3c3a357073df5652232f3f85 /builtin/merge-base.c
parentcommit-reach(repo_in_merge_bases_many): optionally expect missing commits (diff)
downloadgit-24876ebf68baf90075dad5ca3acba8a305f308d4.tar.gz
git-24876ebf68baf90075dad5ca3acba8a305f308d4.zip
commit-reach(repo_in_merge_bases_many): report missing commits
Some functions in Git's source code follow the convention that returning a negative value indicates a fatal error, e.g. repository corruption. Let's use this convention in `repo_in_merge_bases()` to report when one of the specified commits is missing (i.e. when `repo_parse_commit()` reports an error). Also adjust the callers of `repo_in_merge_bases()` to handle such negative return values. Note: As of this patch, errors are returned only if any of the specified merge heads is missing. Over the course of the next patches, missing commits will also be reported by the `paint_down_to_common()` function, which is called by `repo_in_merge_bases_many()`, and those errors will be properly propagated back to the caller at that stage. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/merge-base.c')
-rw-r--r--builtin/merge-base.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/builtin/merge-base.c b/builtin/merge-base.c
index d26e8fbf6f..b0b3838d5f 100644
--- a/builtin/merge-base.c
+++ b/builtin/merge-base.c
@@ -100,12 +100,16 @@ static int handle_octopus(int count, const char **args, int show_all)
static int handle_is_ancestor(int argc, const char **argv)
{
struct commit *one, *two;
+ int ret;
if (argc != 2)
die("--is-ancestor takes exactly two commits");
one = get_commit_reference(argv[0]);
two = get_commit_reference(argv[1]);
- if (repo_in_merge_bases(the_repository, one, two))
+ ret = repo_in_merge_bases(the_repository, one, two);
+ if (ret < 0)
+ exit(128);
+ if (ret)
return 0;
else
return 1;