git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/3] Fixups for cw/submodule-merge-messages
@ 2022-08-17  0:27 Elijah Newren via GitGitGadget
  2022-08-17  0:27 ` [PATCH 1/3] merge-ort: remove translator lego in new "submodule conflict suggestion" Elijah Newren via GitGitGadget
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: Elijah Newren via GitGitGadget @ 2022-08-17  0:27 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren

This series fixes a few issues I noted in cw/submodule-merge-messages (which
merged to next a few days ago). Sorry for not responding before that topic
merged to next; I caught Covid near the end of my vacation and it took me
out for a while. So here are a few patches on top instead.

(Note that my first patch builds on Junio's patch-on-top, though it kind of
obviates the need for his patch. Let me know if you want me to rebase
directly on Calvin's patch and remove the need for your patch, Junio.)

Elijah Newren (3):
  merge-ort: remove translator lego in new "submodule conflict
    suggestion"
  merge-ort: add comment to avoid surprise with new sub_flag variable
  merge-ort: provide helpful submodule update message when possible

 merge-ort.c | 106 +++++++++++++++++-----------------------------------
 1 file changed, 34 insertions(+), 72 deletions(-)


base-commit: 38e3c211f000ebde511099b62be2af104eb20c12
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1325%2Fnewren%2Fsubmodule-merge-messages-fixups-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1325/newren/submodule-merge-messages-fixups-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1325
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/3] merge-ort: remove translator lego in new "submodule conflict suggestion"
  2022-08-17  0:27 [PATCH 0/3] Fixups for cw/submodule-merge-messages Elijah Newren via GitGitGadget
@ 2022-08-17  0:27 ` Elijah Newren via GitGitGadget
  2022-08-17  0:28 ` [PATCH 2/3] merge-ort: add comment to avoid surprise with new sub_flag variable Elijah Newren via GitGitGadget
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 16+ messages in thread
From: Elijah Newren via GitGitGadget @ 2022-08-17  0:27 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

In commit 4057523a40 ("submodule merge: update conflict error message",
2022-08-04), the new "submodule conflict suggestion" code was
translating 6 different pieces of the new message and then used
carefully crafted logic to allow stitching it back together with special
formatting.  Keep the components of the message together as much as
possible, so that:
  * we reduce the number of things translators have to translate
  * translators have more control over the format of the output
  * the code is much easier for developers to understand too

Also, reformat some comments running beyond the 80th column while at it.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 merge-ort.c | 90 +++++++++++++++++------------------------------------
 1 file changed, 28 insertions(+), 62 deletions(-)

diff --git a/merge-ort.c b/merge-ort.c
index f33df3ff65d..67159fc6ef9 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -4481,36 +4481,6 @@ static int record_conflicted_index_entries(struct merge_options *opt)
 	return errs;
 }
 
-static void format_submodule_conflict_suggestion(struct strbuf *msg) {
-	struct strbuf tmp = STRBUF_INIT;
-	struct string_list msg_list = STRING_LIST_INIT_DUP;
-	int i;
-
-	string_list_split(&msg_list, msg->buf, '\n', -1);
-	for (i = 0; i < msg_list.nr; i++) {
-		if (!i)
-			/*
-			 * TRANSLATORS: This is line item of submodule conflict message
-			 * from print_submodule_conflict_suggestion() below. For RTL
-			 * languages, the following swap is suggested:
-			 *      " - %s\n" -> "%s - \n"
-			 */
-			strbuf_addf(&tmp, _(" - %s\n"), msg_list.items[i].string);
-		else
-			/*
-			 * TRANSLATORS: This is line item of submodule conflict message
-			 * from print_submodule_conflict_suggestion() below. For RTL
-			 * languages, the following swap is suggested:
-			 *      "   %s\n" -> "%s   \n"
-			 */
-			strbuf_addf(&tmp, _("   %s\n"), msg_list.items[i].string);
-	}
-	strbuf_reset(msg);
-	strbuf_add(msg, tmp.buf, tmp.len);
-	string_list_clear(&msg_list, 0);
-	strbuf_release(&tmp);
-}
-
 static void print_submodule_conflict_suggestion(struct string_list *csub) {
 	struct string_list_item *item;
 	struct strbuf msg = STRBUF_INIT;
@@ -4532,45 +4502,41 @@ static void print_submodule_conflict_suggestion(struct string_list *csub) {
 			return;
 	}
 
-	printf(_("Recursive merging with submodules currently only supports "
-		"trivial cases.\nPlease manually handle the merging of each "
-		"conflicted submodule.\nThis can be accomplished with the following "
-		"steps:"));
-	putchar('\n');
-
+	strbuf_add_separated_string_list(&subs, " ", csub);
 	for_each_string_list_item(item, csub) {
 		struct conflicted_submodule_item *util = item->util;
+
 		/*
-		 * TRANSLATORS: This is a line of advice to resolve a merge conflict
-		 * in a submodule. The second argument is the abbreviated id of the
-		 * commit that needs to be merged.
-		 * E.g. - go to submodule (sub), and either merge commit abc1234"
+		 * TRANSLATORS: This is a line of advice to resolve a merge
+		 * conflict in a submodule. The first argument is the submodule
+		 * name, and the second argument is the abbreviated id of the
+		 * commit that needs to be merged.  For example:
+		 *  - go to submodule (mysubmodule), and either merge commit abc1234"
 		 */
-		strbuf_addf(&tmp, _("go to submodule (%s), and either merge commit %s\n"
-			"or update to an existing commit which has merged those changes"),
-			item->string, util->abbrev);
-		format_submodule_conflict_suggestion(&tmp);
-		strbuf_add(&msg, tmp.buf, tmp.len);
-		strbuf_reset(&tmp);
+		strbuf_addf(&tmp, _(" - go to submodule (%s), and either merge commit %s\n"
+				    "   or update to an existing commit which has merged those changes\n"),
+			    item->string, util->abbrev);
 	}
-	strbuf_add_separated_string_list(&subs, " ", csub);
-	strbuf_addstr(&tmp, _("come back to superproject and run:"));
-	strbuf_addf(&tmp, "\n\ngit add %s\n\n", subs.buf);
-	strbuf_addstr(&tmp, _("to record the above merge or update"));
-	format_submodule_conflict_suggestion(&tmp);
-	strbuf_add(&msg, tmp.buf, tmp.len);
-	strbuf_reset(&tmp);
-
-	strbuf_addstr(&tmp, _("resolve any other conflicts in the superproject"));
-	format_submodule_conflict_suggestion(&tmp);
-	strbuf_add(&msg, tmp.buf, tmp.len);
-	strbuf_reset(&tmp);
-
-	strbuf_addstr(&tmp, _("commit the resulting index in the superproject"));
-	format_submodule_conflict_suggestion(&tmp);
-	strbuf_add(&msg, tmp.buf, tmp.len);
+
+	/*
+	 * TRANSLATORS: This is a detailed message for resolving submodule
+	 * conflicts.  The first argument is string containing one step per
+	 * submodule.  The second is a space-separated list of submodule names.
+	 */
+	strbuf_addf(&msg,
+		    _("Recursive merging with submodules currently only supports trivial cases.\n"
+		      "Please manually handle the merging of each conflicted submodule.\n"
+		      "This can be accomplished with the following steps:\n"
+		      "%s"
+		      " - come back to superproject and run:\n\n"
+		      "      git add %s\n\n"
+		      "   to record the above merge or update\n"
+		      " - resolve any other conflicts in the superproject\n"
+		      " - commit the resulting index in the superproject\n"),
+		    tmp.buf, subs.buf);
 
 	printf("%s", msg.buf);
+
 	strbuf_release(&subs);
 	strbuf_release(&tmp);
 	strbuf_release(&msg);
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 2/3] merge-ort: add comment to avoid surprise with new sub_flag variable
  2022-08-17  0:27 [PATCH 0/3] Fixups for cw/submodule-merge-messages Elijah Newren via GitGitGadget
  2022-08-17  0:27 ` [PATCH 1/3] merge-ort: remove translator lego in new "submodule conflict suggestion" Elijah Newren via GitGitGadget
@ 2022-08-17  0:28 ` Elijah Newren via GitGitGadget
  2022-08-17  0:28 ` [PATCH 3/3] merge-ort: provide helpful submodule update message when possible Elijah Newren via GitGitGadget
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 16+ messages in thread
From: Elijah Newren via GitGitGadget @ 2022-08-17  0:28 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Commit 4057523a40 ("submodule merge: update conflict error message",
2022-08-04) added a sub_flag variable that is used to store a value from
enum conflict_and_info_types, but initializes it with an invalid value
of -1.  The code may never set it to a valid value, and use the invalid
one.  This can be surprising when reading over the code at first, but it
was intentional.  Add a comment making it clear that it is okay to be
using an invalid value, due to how it is used later.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 merge-ort.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/merge-ort.c b/merge-ort.c
index 67159fc6ef9..0a935a8135f 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -1886,7 +1886,7 @@ cleanup:
 		const char *abbrev;
 
 		util = xmalloc(sizeof(*util));
-		util->flag = sub_flag;
+		util->flag = sub_flag; /* May still be -1 */
 		util->abbrev = NULL;
 		if (!sub_not_initialized) {
 			abbrev = repo_find_unique_abbrev(&subrepo, b, DEFAULT_ABBREV);
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 3/3] merge-ort: provide helpful submodule update message when possible
  2022-08-17  0:27 [PATCH 0/3] Fixups for cw/submodule-merge-messages Elijah Newren via GitGitGadget
  2022-08-17  0:27 ` [PATCH 1/3] merge-ort: remove translator lego in new "submodule conflict suggestion" Elijah Newren via GitGitGadget
  2022-08-17  0:28 ` [PATCH 2/3] merge-ort: add comment to avoid surprise with new sub_flag variable Elijah Newren via GitGitGadget
@ 2022-08-17  0:28 ` Elijah Newren via GitGitGadget
  2022-08-17  5:37 ` [PATCH 0/3] Fixups for cw/submodule-merge-messages Junio C Hamano
  2022-08-17  6:33 ` [PATCH v2 " Elijah Newren via GitGitGadget
  4 siblings, 0 replies; 16+ messages in thread
From: Elijah Newren via GitGitGadget @ 2022-08-17  0:28 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

In commit 4057523a40 ("submodule merge: update conflict error message",
2022-08-04), a more detailed message was provided when submodules
conflict, in order to help users know how to resolve those conflicts.
There were a couple situations for which a different message would be
more appropriate, but that commit left handling those for future work.
Unfortunately, that commit would check if any submodules were of the
type that it didn't know how to explain, and, if so, would avoid
providing the more detailed explanation even for the submodules it did
know how to explain.

Change this to have the code print the helpful messages for the subset
of submodules it knows how to explain.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 merge-ort.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/merge-ort.c b/merge-ort.c
index 0a935a8135f..404f05e32d6 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -4490,21 +4490,17 @@ static void print_submodule_conflict_suggestion(struct string_list *csub) {
 	if (!csub->nr)
 		return;
 
-	/*
-	 * NEEDSWORK: The steps to resolve these errors deserve a more
-	 * detailed explanation than what is currently printed below.
-	 */
+	strbuf_add_separated_string_list(&subs, " ", csub);
 	for_each_string_list_item(item, csub) {
 		struct conflicted_submodule_item *util = item->util;
 
+		/*
+		 * NEEDSWORK: The steps to resolve these errors deserve a more
+		 * detailed explanation than what is currently printed below.
+		 */
 		if (util->flag == CONFLICT_SUBMODULE_NOT_INITIALIZED ||
-			util->flag == CONFLICT_SUBMODULE_HISTORY_NOT_AVAILABLE)
-			return;
-	}
-
-	strbuf_add_separated_string_list(&subs, " ", csub);
-	for_each_string_list_item(item, csub) {
-		struct conflicted_submodule_item *util = item->util;
+		    util->flag == CONFLICT_SUBMODULE_HISTORY_NOT_AVAILABLE)
+			continue;
 
 		/*
 		 * TRANSLATORS: This is a line of advice to resolve a merge
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/3] Fixups for cw/submodule-merge-messages
  2022-08-17  0:27 [PATCH 0/3] Fixups for cw/submodule-merge-messages Elijah Newren via GitGitGadget
                   ` (2 preceding siblings ...)
  2022-08-17  0:28 ` [PATCH 3/3] merge-ort: provide helpful submodule update message when possible Elijah Newren via GitGitGadget
@ 2022-08-17  5:37 ` Junio C Hamano
  2022-08-17  6:33 ` [PATCH v2 " Elijah Newren via GitGitGadget
  4 siblings, 0 replies; 16+ messages in thread
From: Junio C Hamano @ 2022-08-17  5:37 UTC (permalink / raw)
  To: Elijah Newren via GitGitGadget; +Cc: git, Calvin Wan, Elijah Newren

"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:

> (Note that my first patch builds on Junio's patch-on-top, though it kind of
> obviates the need for his patch. Let me know if you want me to rebase
> directly on Calvin's patch and remove the need for your patch, Junio.)

It paid off that I didn't merge the leakfix to 'next' ;-)  Please
just tell me to drop the patch and build on top of what Calvin has
in 'next' directly.

Thanks.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v2 0/3] Fixups for cw/submodule-merge-messages
  2022-08-17  0:27 [PATCH 0/3] Fixups for cw/submodule-merge-messages Elijah Newren via GitGitGadget
                   ` (3 preceding siblings ...)
  2022-08-17  5:37 ` [PATCH 0/3] Fixups for cw/submodule-merge-messages Junio C Hamano
@ 2022-08-17  6:33 ` Elijah Newren via GitGitGadget
  2022-08-17  6:33   ` [PATCH v2 1/3] merge-ort: remove translator lego in new "submodule conflict suggestion" Elijah Newren via GitGitGadget
                     ` (4 more replies)
  4 siblings, 5 replies; 16+ messages in thread
From: Elijah Newren via GitGitGadget @ 2022-08-17  6:33 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren

This series fixes a few issues I noted in cw/submodule-merge-messages (which
merged to next a few days ago). Sorry for not responding before that topic
merged to next; I caught Covid near the end of my vacation and it took me
out for a while. So here are a few patches on top instead.

Changes since v1:

 * rebased directly on top of Calvin's patch, allowing Junio's patch in
   cw/submodule-merge-messages to be dropped.

Elijah Newren (3):
  merge-ort: remove translator lego in new "submodule conflict
    suggestion"
  merge-ort: add comment to avoid surprise with new sub_flag variable
  merge-ort: provide helpful submodule update message when possible

 merge-ort.c | 104 +++++++++++++++++-----------------------------------
 1 file changed, 34 insertions(+), 70 deletions(-)


base-commit: 4057523a4061092e9181220d54dca9eadcb75bdc
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1325%2Fnewren%2Fsubmodule-merge-messages-fixups-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1325/newren/submodule-merge-messages-fixups-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/1325

Range-diff vs v1:

 1:  46c9b48871b ! 1:  374278c6a1d merge-ort: remove translator lego in new "submodule conflict suggestion"
     @@ merge-ort.c: static int record_conflicted_index_entries(struct merge_options *op
      -	}
      -	strbuf_reset(msg);
      -	strbuf_add(msg, tmp.buf, tmp.len);
     --	string_list_clear(&msg_list, 0);
     --	strbuf_release(&tmp);
      -}
      -
       static void print_submodule_conflict_suggestion(struct string_list *csub) {
 2:  269714da706 = 2:  340c0f46f74 merge-ort: add comment to avoid surprise with new sub_flag variable
 3:  010cf4ff344 = 3:  80207d18334 merge-ort: provide helpful submodule update message when possible

-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v2 1/3] merge-ort: remove translator lego in new "submodule conflict suggestion"
  2022-08-17  6:33 ` [PATCH v2 " Elijah Newren via GitGitGadget
@ 2022-08-17  6:33   ` Elijah Newren via GitGitGadget
  2022-08-17  6:33   ` [PATCH v2 2/3] merge-ort: add comment to avoid surprise with new sub_flag variable Elijah Newren via GitGitGadget
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 16+ messages in thread
From: Elijah Newren via GitGitGadget @ 2022-08-17  6:33 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

In commit 4057523a40 ("submodule merge: update conflict error message",
2022-08-04), the new "submodule conflict suggestion" code was
translating 6 different pieces of the new message and then used
carefully crafted logic to allow stitching it back together with special
formatting.  Keep the components of the message together as much as
possible, so that:
  * we reduce the number of things translators have to translate
  * translators have more control over the format of the output
  * the code is much easier for developers to understand too

Also, reformat some comments running beyond the 80th column while at it.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 merge-ort.c | 88 +++++++++++++++++------------------------------------
 1 file changed, 28 insertions(+), 60 deletions(-)

diff --git a/merge-ort.c b/merge-ort.c
index a52faf6e218..67159fc6ef9 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -4481,34 +4481,6 @@ static int record_conflicted_index_entries(struct merge_options *opt)
 	return errs;
 }
 
-static void format_submodule_conflict_suggestion(struct strbuf *msg) {
-	struct strbuf tmp = STRBUF_INIT;
-	struct string_list msg_list = STRING_LIST_INIT_DUP;
-	int i;
-
-	string_list_split(&msg_list, msg->buf, '\n', -1);
-	for (i = 0; i < msg_list.nr; i++) {
-		if (!i)
-			/*
-			 * TRANSLATORS: This is line item of submodule conflict message
-			 * from print_submodule_conflict_suggestion() below. For RTL
-			 * languages, the following swap is suggested:
-			 *      " - %s\n" -> "%s - \n"
-			 */
-			strbuf_addf(&tmp, _(" - %s\n"), msg_list.items[i].string);
-		else
-			/*
-			 * TRANSLATORS: This is line item of submodule conflict message
-			 * from print_submodule_conflict_suggestion() below. For RTL
-			 * languages, the following swap is suggested:
-			 *      "   %s\n" -> "%s   \n"
-			 */
-			strbuf_addf(&tmp, _("   %s\n"), msg_list.items[i].string);
-	}
-	strbuf_reset(msg);
-	strbuf_add(msg, tmp.buf, tmp.len);
-}
-
 static void print_submodule_conflict_suggestion(struct string_list *csub) {
 	struct string_list_item *item;
 	struct strbuf msg = STRBUF_INIT;
@@ -4530,45 +4502,41 @@ static void print_submodule_conflict_suggestion(struct string_list *csub) {
 			return;
 	}
 
-	printf(_("Recursive merging with submodules currently only supports "
-		"trivial cases.\nPlease manually handle the merging of each "
-		"conflicted submodule.\nThis can be accomplished with the following "
-		"steps:"));
-	putchar('\n');
-
+	strbuf_add_separated_string_list(&subs, " ", csub);
 	for_each_string_list_item(item, csub) {
 		struct conflicted_submodule_item *util = item->util;
+
 		/*
-		 * TRANSLATORS: This is a line of advice to resolve a merge conflict
-		 * in a submodule. The second argument is the abbreviated id of the
-		 * commit that needs to be merged.
-		 * E.g. - go to submodule (sub), and either merge commit abc1234"
+		 * TRANSLATORS: This is a line of advice to resolve a merge
+		 * conflict in a submodule. The first argument is the submodule
+		 * name, and the second argument is the abbreviated id of the
+		 * commit that needs to be merged.  For example:
+		 *  - go to submodule (mysubmodule), and either merge commit abc1234"
 		 */
-		strbuf_addf(&tmp, _("go to submodule (%s), and either merge commit %s\n"
-			"or update to an existing commit which has merged those changes"),
-			item->string, util->abbrev);
-		format_submodule_conflict_suggestion(&tmp);
-		strbuf_add(&msg, tmp.buf, tmp.len);
-		strbuf_reset(&tmp);
+		strbuf_addf(&tmp, _(" - go to submodule (%s), and either merge commit %s\n"
+				    "   or update to an existing commit which has merged those changes\n"),
+			    item->string, util->abbrev);
 	}
-	strbuf_add_separated_string_list(&subs, " ", csub);
-	strbuf_addstr(&tmp, _("come back to superproject and run:"));
-	strbuf_addf(&tmp, "\n\ngit add %s\n\n", subs.buf);
-	strbuf_addstr(&tmp, _("to record the above merge or update"));
-	format_submodule_conflict_suggestion(&tmp);
-	strbuf_add(&msg, tmp.buf, tmp.len);
-	strbuf_reset(&tmp);
-
-	strbuf_addstr(&tmp, _("resolve any other conflicts in the superproject"));
-	format_submodule_conflict_suggestion(&tmp);
-	strbuf_add(&msg, tmp.buf, tmp.len);
-	strbuf_reset(&tmp);
-
-	strbuf_addstr(&tmp, _("commit the resulting index in the superproject"));
-	format_submodule_conflict_suggestion(&tmp);
-	strbuf_add(&msg, tmp.buf, tmp.len);
+
+	/*
+	 * TRANSLATORS: This is a detailed message for resolving submodule
+	 * conflicts.  The first argument is string containing one step per
+	 * submodule.  The second is a space-separated list of submodule names.
+	 */
+	strbuf_addf(&msg,
+		    _("Recursive merging with submodules currently only supports trivial cases.\n"
+		      "Please manually handle the merging of each conflicted submodule.\n"
+		      "This can be accomplished with the following steps:\n"
+		      "%s"
+		      " - come back to superproject and run:\n\n"
+		      "      git add %s\n\n"
+		      "   to record the above merge or update\n"
+		      " - resolve any other conflicts in the superproject\n"
+		      " - commit the resulting index in the superproject\n"),
+		    tmp.buf, subs.buf);
 
 	printf("%s", msg.buf);
+
 	strbuf_release(&subs);
 	strbuf_release(&tmp);
 	strbuf_release(&msg);
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 2/3] merge-ort: add comment to avoid surprise with new sub_flag variable
  2022-08-17  6:33 ` [PATCH v2 " Elijah Newren via GitGitGadget
  2022-08-17  6:33   ` [PATCH v2 1/3] merge-ort: remove translator lego in new "submodule conflict suggestion" Elijah Newren via GitGitGadget
@ 2022-08-17  6:33   ` Elijah Newren via GitGitGadget
  2022-08-17 21:45     ` Junio C Hamano
  2022-08-17  6:33   ` [PATCH v2 3/3] merge-ort: provide helpful submodule update message when possible Elijah Newren via GitGitGadget
                     ` (2 subsequent siblings)
  4 siblings, 1 reply; 16+ messages in thread
From: Elijah Newren via GitGitGadget @ 2022-08-17  6:33 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Commit 4057523a40 ("submodule merge: update conflict error message",
2022-08-04) added a sub_flag variable that is used to store a value from
enum conflict_and_info_types, but initializes it with an invalid value
of -1.  The code may never set it to a valid value, and use the invalid
one.  This can be surprising when reading over the code at first, but it
was intentional.  Add a comment making it clear that it is okay to be
using an invalid value, due to how it is used later.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 merge-ort.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/merge-ort.c b/merge-ort.c
index 67159fc6ef9..0a935a8135f 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -1886,7 +1886,7 @@ cleanup:
 		const char *abbrev;
 
 		util = xmalloc(sizeof(*util));
-		util->flag = sub_flag;
+		util->flag = sub_flag; /* May still be -1 */
 		util->abbrev = NULL;
 		if (!sub_not_initialized) {
 			abbrev = repo_find_unique_abbrev(&subrepo, b, DEFAULT_ABBREV);
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 3/3] merge-ort: provide helpful submodule update message when possible
  2022-08-17  6:33 ` [PATCH v2 " Elijah Newren via GitGitGadget
  2022-08-17  6:33   ` [PATCH v2 1/3] merge-ort: remove translator lego in new "submodule conflict suggestion" Elijah Newren via GitGitGadget
  2022-08-17  6:33   ` [PATCH v2 2/3] merge-ort: add comment to avoid surprise with new sub_flag variable Elijah Newren via GitGitGadget
@ 2022-08-17  6:33   ` Elijah Newren via GitGitGadget
  2022-08-17 21:31   ` [PATCH v2 0/3] Fixups for cw/submodule-merge-messages Junio C Hamano
  2022-08-18  7:15   ` [PATCH v3 " Elijah Newren via GitGitGadget
  4 siblings, 0 replies; 16+ messages in thread
From: Elijah Newren via GitGitGadget @ 2022-08-17  6:33 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

In commit 4057523a40 ("submodule merge: update conflict error message",
2022-08-04), a more detailed message was provided when submodules
conflict, in order to help users know how to resolve those conflicts.
There were a couple situations for which a different message would be
more appropriate, but that commit left handling those for future work.
Unfortunately, that commit would check if any submodules were of the
type that it didn't know how to explain, and, if so, would avoid
providing the more detailed explanation even for the submodules it did
know how to explain.

Change this to have the code print the helpful messages for the subset
of submodules it knows how to explain.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 merge-ort.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/merge-ort.c b/merge-ort.c
index 0a935a8135f..404f05e32d6 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -4490,21 +4490,17 @@ static void print_submodule_conflict_suggestion(struct string_list *csub) {
 	if (!csub->nr)
 		return;
 
-	/*
-	 * NEEDSWORK: The steps to resolve these errors deserve a more
-	 * detailed explanation than what is currently printed below.
-	 */
+	strbuf_add_separated_string_list(&subs, " ", csub);
 	for_each_string_list_item(item, csub) {
 		struct conflicted_submodule_item *util = item->util;
 
+		/*
+		 * NEEDSWORK: The steps to resolve these errors deserve a more
+		 * detailed explanation than what is currently printed below.
+		 */
 		if (util->flag == CONFLICT_SUBMODULE_NOT_INITIALIZED ||
-			util->flag == CONFLICT_SUBMODULE_HISTORY_NOT_AVAILABLE)
-			return;
-	}
-
-	strbuf_add_separated_string_list(&subs, " ", csub);
-	for_each_string_list_item(item, csub) {
-		struct conflicted_submodule_item *util = item->util;
+		    util->flag == CONFLICT_SUBMODULE_HISTORY_NOT_AVAILABLE)
+			continue;
 
 		/*
 		 * TRANSLATORS: This is a line of advice to resolve a merge
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 0/3] Fixups for cw/submodule-merge-messages
  2022-08-17  6:33 ` [PATCH v2 " Elijah Newren via GitGitGadget
                     ` (2 preceding siblings ...)
  2022-08-17  6:33   ` [PATCH v2 3/3] merge-ort: provide helpful submodule update message when possible Elijah Newren via GitGitGadget
@ 2022-08-17 21:31   ` Junio C Hamano
  2022-08-18  7:15   ` [PATCH v3 " Elijah Newren via GitGitGadget
  4 siblings, 0 replies; 16+ messages in thread
From: Junio C Hamano @ 2022-08-17 21:31 UTC (permalink / raw)
  To: Elijah Newren via GitGitGadget; +Cc: git, Calvin Wan, Elijah Newren

"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:

> Elijah Newren (3):
>   merge-ort: remove translator lego in new "submodule conflict
>     suggestion"
>   merge-ort: add comment to avoid surprise with new sub_flag variable
>   merge-ort: provide helpful submodule update message when possible

Thanks.  The last step was especially the pleasant one.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 2/3] merge-ort: add comment to avoid surprise with new sub_flag variable
  2022-08-17  6:33   ` [PATCH v2 2/3] merge-ort: add comment to avoid surprise with new sub_flag variable Elijah Newren via GitGitGadget
@ 2022-08-17 21:45     ` Junio C Hamano
  2022-08-18  6:36       ` Elijah Newren
  0 siblings, 1 reply; 16+ messages in thread
From: Junio C Hamano @ 2022-08-17 21:45 UTC (permalink / raw)
  To: Elijah Newren via GitGitGadget; +Cc: git, Calvin Wan, Elijah Newren

"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Elijah Newren <newren@gmail.com>
>
> Commit 4057523a40 ("submodule merge: update conflict error message",
> 2022-08-04) added a sub_flag variable that is used to store a value from
> enum conflict_and_info_types, but initializes it with an invalid value
> of -1.  The code may never set it to a valid value, and use the invalid
> one.  This can be surprising when reading over the code at first, but it
> was intentional.  Add a comment making it clear that it is okay to be
> using an invalid value, due to how it is used later.

The current code uses -1 as the "suggest the default course of
action", so -1 is very much a "valid value" from the viewpoint of
the code that suggests how to resolve.  It indeed is an invalid
value from the viewpoint of those who maintain conflict_and_info_types
enum.

> Signed-off-by: Elijah Newren <newren@gmail.com>
> ---
>  merge-ort.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/merge-ort.c b/merge-ort.c
> index 67159fc6ef9..0a935a8135f 100644
> --- a/merge-ort.c
> +++ b/merge-ort.c
> @@ -1886,7 +1886,7 @@ cleanup:
>  		const char *abbrev;
>  
>  		util = xmalloc(sizeof(*util));
> -		util->flag = sub_flag;
> +		util->flag = sub_flag; /* May still be -1 */
>  		util->abbrev = NULL;
>  		if (!sub_not_initialized) {
>  			abbrev = repo_find_unique_abbrev(&subrepo, b, DEFAULT_ABBREV);

This new comment may be a slight improvement, but a valid value of
sub_flag is used only to signal the situation where the code does
not know what to suggest, which feels backwards for longer-term code
evolution.  Presumably, we would use the util->flag field to store
which of the known cases we know what to suggest as we know better.

I wonder if we should initialize the variable to the most generic
CONFLICT_SUBMODULE_FAILED_TO_MERGE instead of -1.  The value would
mean "use the default suggestion", and the two known unworkable
values (not-initialized and history-not-available) are currently
handled according to what these two values mean.  We may later add
more specialization based on other CONFLICT_SUBMODULE_* values.

Thanks.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 2/3] merge-ort: add comment to avoid surprise with new sub_flag variable
  2022-08-17 21:45     ` Junio C Hamano
@ 2022-08-18  6:36       ` Elijah Newren
  0 siblings, 0 replies; 16+ messages in thread
From: Elijah Newren @ 2022-08-18  6:36 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Elijah Newren via GitGitGadget, Git Mailing List, Calvin Wan

On Wed, Aug 17, 2022 at 2:45 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> > From: Elijah Newren <newren@gmail.com>
> >
> > Commit 4057523a40 ("submodule merge: update conflict error message",
> > 2022-08-04) added a sub_flag variable that is used to store a value from
> > enum conflict_and_info_types, but initializes it with an invalid value
> > of -1.  The code may never set it to a valid value, and use the invalid
> > one.  This can be surprising when reading over the code at first, but it
> > was intentional.  Add a comment making it clear that it is okay to be
> > using an invalid value, due to how it is used later.
>
> The current code uses -1 as the "suggest the default course of
> action", so -1 is very much a "valid value" from the viewpoint of
> the code that suggests how to resolve.  It indeed is an invalid
> value from the viewpoint of those who maintain conflict_and_info_types
> enum.
>
> > Signed-off-by: Elijah Newren <newren@gmail.com>
> > ---
> >  merge-ort.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/merge-ort.c b/merge-ort.c
> > index 67159fc6ef9..0a935a8135f 100644
> > --- a/merge-ort.c
> > +++ b/merge-ort.c
> > @@ -1886,7 +1886,7 @@ cleanup:
> >               const char *abbrev;
> >
> >               util = xmalloc(sizeof(*util));
> > -             util->flag = sub_flag;
> > +             util->flag = sub_flag; /* May still be -1 */
> >               util->abbrev = NULL;
> >               if (!sub_not_initialized) {
> >                       abbrev = repo_find_unique_abbrev(&subrepo, b, DEFAULT_ABBREV);
>
> This new comment may be a slight improvement, but a valid value of
> sub_flag is used only to signal the situation where the code does
> not know what to suggest, which feels backwards for longer-term code
> evolution.  Presumably, we would use the util->flag field to store
> which of the known cases we know what to suggest as we know better.
>
> I wonder if we should initialize the variable to the most generic
> CONFLICT_SUBMODULE_FAILED_TO_MERGE instead of -1.  The value would
> mean "use the default suggestion", and the two known unworkable
> values (not-initialized and history-not-available) are currently
> handled according to what these two values mean.  We may later add
> more specialization based on other CONFLICT_SUBMODULE_* values.

I like that; I'll make the switch.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v3 0/3] Fixups for cw/submodule-merge-messages
  2022-08-17  6:33 ` [PATCH v2 " Elijah Newren via GitGitGadget
                     ` (3 preceding siblings ...)
  2022-08-17 21:31   ` [PATCH v2 0/3] Fixups for cw/submodule-merge-messages Junio C Hamano
@ 2022-08-18  7:15   ` Elijah Newren via GitGitGadget
  2022-08-18  7:15     ` [PATCH v3 1/3] merge-ort: remove translator lego in new "submodule conflict suggestion" Elijah Newren via GitGitGadget
                       ` (2 more replies)
  4 siblings, 3 replies; 16+ messages in thread
From: Elijah Newren via GitGitGadget @ 2022-08-18  7:15 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

This series fixes a few issues I noted in cw/submodule-merge-messages (which
merged to next a few days ago). Sorry for not responding before that topic
merged to next; I caught Covid near the end of my vacation and it took me
out for a while. So here are a few patches on top instead.

Changes since v1:

 * rebased directly on top of Calvin's patch, allowing Junio's patch in
   cw/submodule-merge-messages to be dropped.

Changes since v2:

 * changed the second patch to instead initialize sub_flag to
   CONFLICT_SUBMODULE_FAILED_TO_MERGE, as suggested by Junio. (thanks!)

Elijah Newren (3):
  merge-ort: remove translator lego in new "submodule conflict
    suggestion"
  merge-ort: avoid surprise with new sub_flag variable
  merge-ort: provide helpful submodule update message when possible

 merge-ort.c | 104 +++++++++++++++++-----------------------------------
 1 file changed, 34 insertions(+), 70 deletions(-)


base-commit: 4057523a4061092e9181220d54dca9eadcb75bdc
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1325%2Fnewren%2Fsubmodule-merge-messages-fixups-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1325/newren/submodule-merge-messages-fixups-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/1325

Range-diff vs v2:

 1:  374278c6a1d = 1:  374278c6a1d merge-ort: remove translator lego in new "submodule conflict suggestion"
 2:  340c0f46f74 < -:  ----------- merge-ort: add comment to avoid surprise with new sub_flag variable
 -:  ----------- > 2:  48200773a1b merge-ort: avoid surprise with new sub_flag variable
 3:  80207d18334 = 3:  4c4a8f028d4 merge-ort: provide helpful submodule update message when possible

-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v3 1/3] merge-ort: remove translator lego in new "submodule conflict suggestion"
  2022-08-18  7:15   ` [PATCH v3 " Elijah Newren via GitGitGadget
@ 2022-08-18  7:15     ` Elijah Newren via GitGitGadget
  2022-08-18  7:15     ` [PATCH v3 2/3] merge-ort: avoid surprise with new sub_flag variable Elijah Newren via GitGitGadget
  2022-08-18  7:15     ` [PATCH v3 3/3] merge-ort: provide helpful submodule update message when possible Elijah Newren via GitGitGadget
  2 siblings, 0 replies; 16+ messages in thread
From: Elijah Newren via GitGitGadget @ 2022-08-18  7:15 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

In commit 4057523a40 ("submodule merge: update conflict error message",
2022-08-04), the new "submodule conflict suggestion" code was
translating 6 different pieces of the new message and then used
carefully crafted logic to allow stitching it back together with special
formatting.  Keep the components of the message together as much as
possible, so that:
  * we reduce the number of things translators have to translate
  * translators have more control over the format of the output
  * the code is much easier for developers to understand too

Also, reformat some comments running beyond the 80th column while at it.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 merge-ort.c | 88 +++++++++++++++++------------------------------------
 1 file changed, 28 insertions(+), 60 deletions(-)

diff --git a/merge-ort.c b/merge-ort.c
index a52faf6e218..67159fc6ef9 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -4481,34 +4481,6 @@ static int record_conflicted_index_entries(struct merge_options *opt)
 	return errs;
 }
 
-static void format_submodule_conflict_suggestion(struct strbuf *msg) {
-	struct strbuf tmp = STRBUF_INIT;
-	struct string_list msg_list = STRING_LIST_INIT_DUP;
-	int i;
-
-	string_list_split(&msg_list, msg->buf, '\n', -1);
-	for (i = 0; i < msg_list.nr; i++) {
-		if (!i)
-			/*
-			 * TRANSLATORS: This is line item of submodule conflict message
-			 * from print_submodule_conflict_suggestion() below. For RTL
-			 * languages, the following swap is suggested:
-			 *      " - %s\n" -> "%s - \n"
-			 */
-			strbuf_addf(&tmp, _(" - %s\n"), msg_list.items[i].string);
-		else
-			/*
-			 * TRANSLATORS: This is line item of submodule conflict message
-			 * from print_submodule_conflict_suggestion() below. For RTL
-			 * languages, the following swap is suggested:
-			 *      "   %s\n" -> "%s   \n"
-			 */
-			strbuf_addf(&tmp, _("   %s\n"), msg_list.items[i].string);
-	}
-	strbuf_reset(msg);
-	strbuf_add(msg, tmp.buf, tmp.len);
-}
-
 static void print_submodule_conflict_suggestion(struct string_list *csub) {
 	struct string_list_item *item;
 	struct strbuf msg = STRBUF_INIT;
@@ -4530,45 +4502,41 @@ static void print_submodule_conflict_suggestion(struct string_list *csub) {
 			return;
 	}
 
-	printf(_("Recursive merging with submodules currently only supports "
-		"trivial cases.\nPlease manually handle the merging of each "
-		"conflicted submodule.\nThis can be accomplished with the following "
-		"steps:"));
-	putchar('\n');
-
+	strbuf_add_separated_string_list(&subs, " ", csub);
 	for_each_string_list_item(item, csub) {
 		struct conflicted_submodule_item *util = item->util;
+
 		/*
-		 * TRANSLATORS: This is a line of advice to resolve a merge conflict
-		 * in a submodule. The second argument is the abbreviated id of the
-		 * commit that needs to be merged.
-		 * E.g. - go to submodule (sub), and either merge commit abc1234"
+		 * TRANSLATORS: This is a line of advice to resolve a merge
+		 * conflict in a submodule. The first argument is the submodule
+		 * name, and the second argument is the abbreviated id of the
+		 * commit that needs to be merged.  For example:
+		 *  - go to submodule (mysubmodule), and either merge commit abc1234"
 		 */
-		strbuf_addf(&tmp, _("go to submodule (%s), and either merge commit %s\n"
-			"or update to an existing commit which has merged those changes"),
-			item->string, util->abbrev);
-		format_submodule_conflict_suggestion(&tmp);
-		strbuf_add(&msg, tmp.buf, tmp.len);
-		strbuf_reset(&tmp);
+		strbuf_addf(&tmp, _(" - go to submodule (%s), and either merge commit %s\n"
+				    "   or update to an existing commit which has merged those changes\n"),
+			    item->string, util->abbrev);
 	}
-	strbuf_add_separated_string_list(&subs, " ", csub);
-	strbuf_addstr(&tmp, _("come back to superproject and run:"));
-	strbuf_addf(&tmp, "\n\ngit add %s\n\n", subs.buf);
-	strbuf_addstr(&tmp, _("to record the above merge or update"));
-	format_submodule_conflict_suggestion(&tmp);
-	strbuf_add(&msg, tmp.buf, tmp.len);
-	strbuf_reset(&tmp);
-
-	strbuf_addstr(&tmp, _("resolve any other conflicts in the superproject"));
-	format_submodule_conflict_suggestion(&tmp);
-	strbuf_add(&msg, tmp.buf, tmp.len);
-	strbuf_reset(&tmp);
-
-	strbuf_addstr(&tmp, _("commit the resulting index in the superproject"));
-	format_submodule_conflict_suggestion(&tmp);
-	strbuf_add(&msg, tmp.buf, tmp.len);
+
+	/*
+	 * TRANSLATORS: This is a detailed message for resolving submodule
+	 * conflicts.  The first argument is string containing one step per
+	 * submodule.  The second is a space-separated list of submodule names.
+	 */
+	strbuf_addf(&msg,
+		    _("Recursive merging with submodules currently only supports trivial cases.\n"
+		      "Please manually handle the merging of each conflicted submodule.\n"
+		      "This can be accomplished with the following steps:\n"
+		      "%s"
+		      " - come back to superproject and run:\n\n"
+		      "      git add %s\n\n"
+		      "   to record the above merge or update\n"
+		      " - resolve any other conflicts in the superproject\n"
+		      " - commit the resulting index in the superproject\n"),
+		    tmp.buf, subs.buf);
 
 	printf("%s", msg.buf);
+
 	strbuf_release(&subs);
 	strbuf_release(&tmp);
 	strbuf_release(&msg);
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v3 2/3] merge-ort: avoid surprise with new sub_flag variable
  2022-08-18  7:15   ` [PATCH v3 " Elijah Newren via GitGitGadget
  2022-08-18  7:15     ` [PATCH v3 1/3] merge-ort: remove translator lego in new "submodule conflict suggestion" Elijah Newren via GitGitGadget
@ 2022-08-18  7:15     ` Elijah Newren via GitGitGadget
  2022-08-18  7:15     ` [PATCH v3 3/3] merge-ort: provide helpful submodule update message when possible Elijah Newren via GitGitGadget
  2 siblings, 0 replies; 16+ messages in thread
From: Elijah Newren via GitGitGadget @ 2022-08-18  7:15 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Commit 4057523a40 ("submodule merge: update conflict error message",
2022-08-04) added a sub_flag variable that is used to store a value from
enum conflict_and_info_types, but initializes it with a value of -1 that
does not correspond to any of the conflict_and_info_types.  The code may
never set it to a valid value and yet still use it, which can be
surprising when reading over the code at first.  Initialize it instead
to the generic CONFLICT_SUBMODULE_FAILED_TO_MERGE value, which is still
distinct from the two values we need to special case.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 merge-ort.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/merge-ort.c b/merge-ort.c
index 67159fc6ef9..8f14f1ad0b2 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -1767,7 +1767,7 @@ static int merge_submodule(struct merge_options *opt,
 	int i;
 	int search = !opt->priv->call_depth;
 	int sub_not_initialized = 1;
-	int sub_flag = -1;
+	int sub_flag = CONFLICT_SUBMODULE_FAILED_TO_MERGE;
 
 	/* store fallback answer in result in case we fail */
 	oidcpy(result, opt->priv->call_depth ? o : a);
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v3 3/3] merge-ort: provide helpful submodule update message when possible
  2022-08-18  7:15   ` [PATCH v3 " Elijah Newren via GitGitGadget
  2022-08-18  7:15     ` [PATCH v3 1/3] merge-ort: remove translator lego in new "submodule conflict suggestion" Elijah Newren via GitGitGadget
  2022-08-18  7:15     ` [PATCH v3 2/3] merge-ort: avoid surprise with new sub_flag variable Elijah Newren via GitGitGadget
@ 2022-08-18  7:15     ` Elijah Newren via GitGitGadget
  2 siblings, 0 replies; 16+ messages in thread
From: Elijah Newren via GitGitGadget @ 2022-08-18  7:15 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

In commit 4057523a40 ("submodule merge: update conflict error message",
2022-08-04), a more detailed message was provided when submodules
conflict, in order to help users know how to resolve those conflicts.
There were a couple situations for which a different message would be
more appropriate, but that commit left handling those for future work.
Unfortunately, that commit would check if any submodules were of the
type that it didn't know how to explain, and, if so, would avoid
providing the more detailed explanation even for the submodules it did
know how to explain.

Change this to have the code print the helpful messages for the subset
of submodules it knows how to explain.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 merge-ort.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/merge-ort.c b/merge-ort.c
index 8f14f1ad0b2..d94e3f17d7b 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -4490,21 +4490,17 @@ static void print_submodule_conflict_suggestion(struct string_list *csub) {
 	if (!csub->nr)
 		return;
 
-	/*
-	 * NEEDSWORK: The steps to resolve these errors deserve a more
-	 * detailed explanation than what is currently printed below.
-	 */
+	strbuf_add_separated_string_list(&subs, " ", csub);
 	for_each_string_list_item(item, csub) {
 		struct conflicted_submodule_item *util = item->util;
 
+		/*
+		 * NEEDSWORK: The steps to resolve these errors deserve a more
+		 * detailed explanation than what is currently printed below.
+		 */
 		if (util->flag == CONFLICT_SUBMODULE_NOT_INITIALIZED ||
-			util->flag == CONFLICT_SUBMODULE_HISTORY_NOT_AVAILABLE)
-			return;
-	}
-
-	strbuf_add_separated_string_list(&subs, " ", csub);
-	for_each_string_list_item(item, csub) {
-		struct conflicted_submodule_item *util = item->util;
+		    util->flag == CONFLICT_SUBMODULE_HISTORY_NOT_AVAILABLE)
+			continue;
 
 		/*
 		 * TRANSLATORS: This is a line of advice to resolve a merge
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2022-08-18  7:16 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-17  0:27 [PATCH 0/3] Fixups for cw/submodule-merge-messages Elijah Newren via GitGitGadget
2022-08-17  0:27 ` [PATCH 1/3] merge-ort: remove translator lego in new "submodule conflict suggestion" Elijah Newren via GitGitGadget
2022-08-17  0:28 ` [PATCH 2/3] merge-ort: add comment to avoid surprise with new sub_flag variable Elijah Newren via GitGitGadget
2022-08-17  0:28 ` [PATCH 3/3] merge-ort: provide helpful submodule update message when possible Elijah Newren via GitGitGadget
2022-08-17  5:37 ` [PATCH 0/3] Fixups for cw/submodule-merge-messages Junio C Hamano
2022-08-17  6:33 ` [PATCH v2 " Elijah Newren via GitGitGadget
2022-08-17  6:33   ` [PATCH v2 1/3] merge-ort: remove translator lego in new "submodule conflict suggestion" Elijah Newren via GitGitGadget
2022-08-17  6:33   ` [PATCH v2 2/3] merge-ort: add comment to avoid surprise with new sub_flag variable Elijah Newren via GitGitGadget
2022-08-17 21:45     ` Junio C Hamano
2022-08-18  6:36       ` Elijah Newren
2022-08-17  6:33   ` [PATCH v2 3/3] merge-ort: provide helpful submodule update message when possible Elijah Newren via GitGitGadget
2022-08-17 21:31   ` [PATCH v2 0/3] Fixups for cw/submodule-merge-messages Junio C Hamano
2022-08-18  7:15   ` [PATCH v3 " Elijah Newren via GitGitGadget
2022-08-18  7:15     ` [PATCH v3 1/3] merge-ort: remove translator lego in new "submodule conflict suggestion" Elijah Newren via GitGitGadget
2022-08-18  7:15     ` [PATCH v3 2/3] merge-ort: avoid surprise with new sub_flag variable Elijah Newren via GitGitGadget
2022-08-18  7:15     ` [PATCH v3 3/3] merge-ort: provide helpful submodule update message when possible Elijah Newren via GitGitGadget

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).