git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Patrick Steinhardt <ps@pks.im>, Dirk Gouders <dirk@gouders.net>,
	Jeff King <peff@peff.net>,
	Johannes Schindelin <johannes.schindelin@gmx.de>,
	Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: [PATCH 1/2] merge-recursive: prepare for `merge_submodule()` to report errors
Date: Sat, 09 Mar 2024 14:09:56 +0000	[thread overview]
Message-ID: <533df4c6659439d0a241a8b2e329c88d475d4136.1709993397.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1686.git.1709993397.gitgitgadget@gmail.com>

From: Johannes Schindelin <johannes.schindelin@gmx.de>

The `merge_submodule()` function returns an integer that indicates
whether the merge was clean (returning 1) or unclean (returning 0).

Like the version in `merge-ort.c`, the version in `merge-recursive.c`
does not report any errors (such as repository corruption) by returning
-1 as of time of writing, even if the callers in `merge-ort.c` are
prepared for exactly such errors.

However, we want to teach (both variants of) the `merge_submodule()`
function that trick: to report errors by returning -1. Therefore,
prepare the caller in `merge-recursive.c` to handle that scenario.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 merge-recursive.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/merge-recursive.c b/merge-recursive.c
index 32e9d6665de..f3132a9ecae 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1426,13 +1426,14 @@ static int merge_mode_and_contents(struct merge_options *opt,
 			/* FIXME: bug, what if modes didn't match? */
 			result->clean = (merge_status == 0);
 		} else if (S_ISGITLINK(a->mode)) {
-			result->clean = merge_submodule(opt, &result->blob.oid,
-							o->path,
-							&o->oid,
-							&a->oid,
-							&b->oid);
-			if (result->clean < 0)
+			int clean = merge_submodule(opt, &result->blob.oid,
+						    o->path,
+						    &o->oid,
+						    &a->oid,
+						    &b->oid);
+			if (clean < 0)
 				return -1;
+			result->clean = clean;
 		} else if (S_ISLNK(a->mode)) {
 			switch (opt->recursive_variant) {
 			case MERGE_VARIANT_NORMAL:
-- 
gitgitgadget


  reply	other threads:[~2024-03-09 14:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-09 14:09 [PATCH 0/2] The merge-base logic vs missing commit objects (follow-up) Johannes Schindelin via GitGitGadget
2024-03-09 14:09 ` Johannes Schindelin via GitGitGadget [this message]
2024-03-09 14:09 ` [PATCH 2/2] merge-ort/merge-recursive: do report errors in `merge_submodule()` Johannes Schindelin via GitGitGadget
2024-03-09 17:56   ` Junio C Hamano
2024-03-09 20:46     ` Johannes Schindelin
2024-03-09 23:18       ` Junio C Hamano
2024-03-09 16:51 ` [PATCH 0/2] The merge-base logic vs missing commit objects (follow-up) Elijah Newren
2024-03-09 17:56   ` Junio C Hamano
2024-03-09 17:45 ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=533df4c6659439d0a241a8b2e329c88d475d4136.1709993397.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=dirk@gouders.net \
    --cc=git@vger.kernel.org \
    --cc=johannes.schindelin@gmx.de \
    --cc=peff@peff.net \
    --cc=ps@pks.im \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).