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

[PATCH v3 2/3] merge-ort: avoid surprise with new sub_flag variable

From
Elijah Newren via GitGitGadget <gitgitgadget@gmail.com>
Date
Aug 18, 2022, 07:15 UTC
Message-ID
<48200773a1bbe8467e37db637c99c85be2c809ec.1660806927.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1325.v3.git.1660806927.gitgitgadget@gmail.com>
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
Previous: Elijah Newren via GitGitGadgetNext: Elijah Newren via GitGitGadget
Message 15 of 16 in “Fixups for cw/submodule-merge-messages”
  1. 0/3 Fixups for cw/submodule-merge-messagesElijah Newren via GitGitGadget, Aug 17, 2022
  2. 1/3 merge-ort: remove translator lego in new "submodule conflict suggestion"Elijah Newren via GitGitGadget, Aug 17, 2022
  3. 2/3 merge-ort: add comment to avoid surprise with new sub_flag variableElijah Newren via GitGitGadget, Aug 17, 2022
  4. 3/3 merge-ort: provide helpful submodule update message when possibleElijah Newren via GitGitGadget, Aug 17, 2022
  5. Junio C HamanoAug 17, 2022
  6. 0/3 Fixups for cw/submodule-merge-messagesElijah Newren via GitGitGadget, Aug 17, 2022
  7. 1/3 merge-ort: remove translator lego in new "submodule conflict suggestion"Elijah Newren via GitGitGadget, Aug 17, 2022
  8. 2/3 merge-ort: add comment to avoid surprise with new sub_flag variableElijah Newren via GitGitGadget, Aug 17, 2022
  9. Junio C HamanoAug 17, 2022
  10. Elijah NewrenAug 18, 2022
  11. 3/3 merge-ort: provide helpful submodule update message when possibleElijah Newren via GitGitGadget, Aug 17, 2022
  12. Junio C HamanoAug 17, 2022
  13. 0/3 Fixups for cw/submodule-merge-messagesElijah Newren via GitGitGadget, Aug 18, 2022
  14. 1/3 merge-ort: remove translator lego in new "submodule conflict suggestion"Elijah Newren via GitGitGadget, Aug 18, 2022
  15. 2/3 merge-ort: avoid surprise with new sub_flag variableElijah Newren via GitGitGadget, Aug 18, 2022
  16. 3/3 merge-ort: provide helpful submodule update message when possibleElijah Newren via GitGitGadget, Aug 18, 2022

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.