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

[PATCH 3/4] rerere: try_merge() should use LL_MERGE_ERROR when it means an error

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 24, 2023, 20:54 UTC
Message-ID
<20230824205456.1231371-4-gitster@pobox.com>
In-Reply-To
<20230824205456.1231371-1-gitster@pobox.com>

When the preimage or the postimage files cannot be read, the try_merge() helper function returns LL_MERGE_CONFLICT. To all of its callers, this does not make them do wrong things per-se, as they are only checking if the result is 0 and LL_MERGE_CONFLICT is not 0.

But it is an error if we fail to read the input we expect to be able to read; return LL_MERGE_ERROR instead. This does not change any behaviour---it just makes the code use the "correct" constant to signal an error.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 rerere.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rerere.c b/rerere.c
index 4ce1270a94..6bc3c54d3b 100644
--- a/rerere.c
+++ b/rerere.c
@@ -617,7 +617,7 @@ static int try_merge(struct index_state *istate,
 
 	if (read_mmfile(&base, rerere_path(id, "preimage")) ||
 	    read_mmfile(&other, rerere_path(id, "postimage"))) {
-		ret = LL_MERGE_CONFLICT;
+		ret = LL_MERGE_ERROR;
 	} else {
 		/*
 		 * A three-way merge. Note that this honors user-customizable
-- 
2.42.0-29-gcd9da15a85
Previous: Junio C HamanoNext: Junio C Hamano
Message 2 of 5 in “code clean-up for rerere”
  1. 0/4 code clean-up for rerereJunio C Hamano, Aug 24, 2023
  2. 3/4 rerere: try_merge() should use LL_MERGE_ERROR when it means an errorJunio C Hamano, Aug 24, 2023
  3. 1/4 rerere: simplify check_one_conflict() helper functionJunio C Hamano, Aug 24, 2023
  4. 4/4 rerere: modernize use of empty strbufJunio C Hamano, Aug 24, 2023
  5. 2/4 rerere: fix comment on handle_file() helperJunio C Hamano, Aug 24, 2023

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.