summaryrefslogtreecommitdiffstats
path: root/builtin/merge.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-03-11 22:12:30 +0100
committerJunio C Hamano <gitster@pobox.com>2024-03-11 22:12:30 +0100
commit7745f92507517c4e60dc2a7faad40eee49ee670b (patch)
treef9eb30d1767f40a69db6b874f50bbdc8953d745d /builtin/merge.c
parentThe fifth batch (diff)
parentmerge-ort/merge-recursive: do report errors in `merge_submodule()` (diff)
downloadgit-7745f92507517c4e60dc2a7faad40eee49ee670b.tar.xz
git-7745f92507517c4e60dc2a7faad40eee49ee670b.zip
Merge branch 'js/merge-base-with-missing-commit'
Make sure failure return from merge_bases_many() is properly caught. * js/merge-base-with-missing-commit: merge-ort/merge-recursive: do report errors in `merge_submodule()` merge-recursive: prepare for `merge_submodule()` to report errors commit-reach(repo_get_merge_bases_many_dirty): pass on errors commit-reach(repo_get_merge_bases_many): pass on "missing commits" errors commit-reach(get_octopus_merge_bases): pass on "missing commits" errors commit-reach(repo_get_merge_bases): pass on "missing commits" errors commit-reach(get_merge_bases_many_0): pass on "missing commits" errors commit-reach(merge_bases_many): pass on "missing commits" errors commit-reach(paint_down_to_common): start reporting errors commit-reach(paint_down_to_common): prepare for handling shallow commits commit-reach(repo_in_merge_bases_many): report missing commits commit-reach(repo_in_merge_bases_many): optionally expect missing commits commit-reach(paint_down_to_common): plug two memory leaks
Diffstat (limited to 'builtin/merge.c')
-rw-r--r--builtin/merge.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/builtin/merge.c b/builtin/merge.c
index 935c8a57dd..a0ba1f9815 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1513,13 +1513,20 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
if (!remoteheads)
; /* already up-to-date */
- else if (!remoteheads->next)
- common = repo_get_merge_bases(the_repository, head_commit,
- remoteheads->item);
- else {
+ else if (!remoteheads->next) {
+ if (repo_get_merge_bases(the_repository, head_commit,
+ remoteheads->item, &common) < 0) {
+ ret = 2;
+ goto done;
+ }
+ } else {
struct commit_list *list = remoteheads;
commit_list_insert(head_commit, &list);
- common = get_octopus_merge_bases(list);
+ if (get_octopus_merge_bases(list, &common) < 0) {
+ free(list);
+ ret = 2;
+ goto done;
+ }
free(list);
}
@@ -1626,7 +1633,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
struct commit_list *j;
for (j = remoteheads; j; j = j->next) {
- struct commit_list *common_one;
+ struct commit_list *common_one = NULL;
struct commit *common_item;
/*
@@ -1634,9 +1641,10 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
* merge_bases again, otherwise "git merge HEAD^
* HEAD^^" would be missed.
*/
- common_one = repo_get_merge_bases(the_repository,
- head_commit,
- j->item);
+ if (repo_get_merge_bases(the_repository, head_commit,
+ j->item, &common_one) < 0)
+ exit(128);
+
common_item = common_one->item;
free_commit_list(common_one);
if (!oideq(&common_item->object.oid, &j->item->object.oid)) {