git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] merge-ort/merge-recursive: do report errors in `merge_submodule()`

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Mar 9, 2024, 14:09 UTC
Message-ID
<50fe1a26515c06afec5ac7fb723727e1365a14fc.1709993397.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1686.git.1709993397.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

In 24876ebf68b (commit-reach(repo_in_merge_bases_many): report missing commits, 2024-02-28), I taught `merge_submodule()` to handle errors reported by `repo_in_merge_bases_many()`.

However, those errors were not passed through to the callers. That was unintentional, and this commit remedies that.

Note that `find_first_merges()` can now also return -1 (because it passes through that return value from `repo_in_merge_bases()`), and this commit also adds the forgotten handling for that scenario.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 merge-ort.c       | 5 +++++
 merge-recursive.c | 8 ++++++++
 2 files changed, 13 insertions(+)
diff --git a/merge-ort.c b/merge-ort.c
index 033c4348e2d..5d36c04f509 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -1819,6 +1819,7 @@ static int merge_submodule(struct merge_options *opt,
 			 _("Failed to merge submodule %s "
 			   "(repository corrupt)"),
 			 path);
+		ret = -1;
 		goto cleanup;
 	}
 	if (ret2 > 0)
@@ -1829,6 +1830,7 @@ static int merge_submodule(struct merge_options *opt,
 			 _("Failed to merge submodule %s "
 			   "(repository corrupt)"),
 			 path);
+		ret = -1;
 		goto cleanup;
 	}
 	if (!ret2) {
@@ -1848,6 +1850,7 @@ static int merge_submodule(struct merge_options *opt,
 			 _("Failed to merge submodule %s "
 			   "(repository corrupt)"),
 			 path);
+		ret = -1;
 		goto cleanup;
 	}
 	if (ret2 > 0) {
@@ -1866,6 +1869,7 @@ static int merge_submodule(struct merge_options *opt,
 			 _("Failed to merge submodule %s "
 			   "(repository corrupt)"),
 			 path);
+		ret = -1;
 		goto cleanup;
 	}
 	if (ret2 > 0) {
@@ -1899,6 +1903,7 @@ static int merge_submodule(struct merge_options *opt,
 			 _("Failed to merge submodule %s "
 			   "(repository corrupt)"),
 			 path);
+		ret = -1;
 		break;
 	case 0:
 		path_msg(opt, CONFLICT_SUBMODULE_FAILED_TO_MERGE, 0,
diff --git a/merge-recursive.c b/merge-recursive.c
index f3132a9ecae..fc772c2b113 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1246,12 +1246,14 @@ static int merge_submodule(struct merge_options *opt,
 	ret2 = repo_in_merge_bases(&subrepo, commit_base, commit_a);
 	if (ret2 < 0) {
 		output(opt, 1, _("Failed to merge submodule %s (repository corrupt)"), path);
+		ret = -1;
 		goto cleanup;
 	}
 	if (ret2 > 0)
 		ret2 = repo_in_merge_bases(&subrepo, commit_base, commit_b);
 	if (ret2 < 0) {
 		output(opt, 1, _("Failed to merge submodule %s (repository corrupt)"), path);
+		ret = -1;
 		goto cleanup;
 	}
 	if (!ret2) {
@@ -1263,6 +1265,7 @@ static int merge_submodule(struct merge_options *opt,
 	ret2 = repo_in_merge_bases(&subrepo, commit_a, commit_b);
 	if (ret2 < 0) {
 		output(opt, 1, _("Failed to merge submodule %s (repository corrupt)"), path);
+		ret = -1;
 		goto cleanup;
 	}
 	if (ret2) {
@@ -1281,6 +1284,7 @@ static int merge_submodule(struct merge_options *opt,
 	ret2 = repo_in_merge_bases(&subrepo, commit_b, commit_a);
 	if (ret2 < 0) {
 		output(opt, 1, _("Failed to merge submodule %s (repository corrupt)"), path);
+		ret = -1;
 		goto cleanup;
 	}
 	if (ret2) {
@@ -1312,6 +1316,10 @@ static int merge_submodule(struct merge_options *opt,
 	parent_count = find_first_merges(&subrepo, &merges, path,
 					 commit_a, commit_b);
 	switch (parent_count) {
+	case -1:
+		output(opt, 1,_("Failed to merge submodule %s (repository corrupt)"), path);
+		ret = -1;
+		break;
 	case 0:
 		output(opt, 1, _("Failed to merge submodule %s (merge following commits not found)"), path);
 		break;
-- 
gitgitgadget
Previous: Johannes Schindelin via GitGitGadgetNext: Junio C Hamano
Message 3 of 9 in “The merge-base logic vs missing commit objects (follow-up)”
  1. 0/2 The merge-base logic vs missing commit objects (follow-up)Johannes Schindelin via GitGitGadget, Mar 9, 2024
  2. 1/2 merge-recursive: prepare for `merge_submodule()` to report errorsJohannes Schindelin via GitGitGadget, Mar 9, 2024
  3. 2/2 merge-ort/merge-recursive: do report errors in `merge_submodule()`Johannes Schindelin via GitGitGadget, Mar 9, 2024
  4. Junio C HamanoMar 9, 2024
  5. Johannes SchindelinMar 9, 2024
  6. Junio C HamanoMar 9, 2024
  7. Elijah NewrenMar 9, 2024
  8. Junio C HamanoMar 9, 2024
  9. Junio C HamanoMar 9, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.