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

[PATCH 2/4] merge: fix Yoda conditions

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Jun 13, 2021, 22:58 UTC
Message-ID
<20210613225836.1009569-3-felipe.contreras@gmail.com>
In-Reply-To
<20210613225836.1009569-1-felipe.contreras@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 builtin/merge-file.c | 2 +-
 xdiff/xmerge.c       | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/builtin/merge-file.c b/builtin/merge-file.c
index 0186f4156a..6affccaf19 100644
--- a/builtin/merge-file.c
+++ b/builtin/merge-file.c
@@ -51,7 +51,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
 	if (startup_info->have_repository) {
 		/* Read the configuration file */
 		git_config(git_xmerge_config, NULL);
-		if (0 <= git_xmerge_style)
+		if (git_xmerge_style >= 0)
 			xmp.style = git_xmerge_style;
 	}
 
diff --git a/xdiff/xmerge.c b/xdiff/xmerge.c
index 1659edb453..ab3448ca88 100644
--- a/xdiff/xmerge.c
+++ b/xdiff/xmerge.c
@@ -487,7 +487,7 @@ static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1,
 		 * "diff3 -m" output does not make sense for anything
 		 * more aggressive than XDL_MERGE_EAGER.
 		 */
-		if (XDL_MERGE_EAGER < level)
+		if (level > XDL_MERGE_EAGER)
 			level = XDL_MERGE_EAGER;
 	}
 
@@ -603,10 +603,10 @@ static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1,
 	if (!changes)
 		changes = c;
 	/* refine conflicts */
-	if (XDL_MERGE_ZEALOUS <= level &&
+	if (level >= XDL_MERGE_ZEALOUS &&
 	    (xdl_refine_conflicts(xe1, xe2, changes, xpp) < 0 ||
 	     xdl_simplify_non_conflicts(xe1, changes,
-					XDL_MERGE_ZEALOUS < level) < 0)) {
+					level > XDL_MERGE_ZEALOUS) < 0)) {
 		xdl_cleanup_merge(changes);
 		return -1;
 	}
-- 
2.32.0
Previous: Felipe ContrerasNext: Felipe Contreras
Message 9 of 10 in “merge: cleanups and fix”
  1. 0/4 merge: cleanups and fixFelipe Contreras, Jun 13, 2021
  2. 4/4 xdiff/xmerge: fix chg0 initializationFelipe Contreras, Jun 13, 2021
  3. Elijah NewrenJun 14, 2021
  4. Felipe ContrerasJun 15, 2021
  5. Elijah NewrenJun 15, 2021
  6. 1/4 merge: simplify initializationFelipe Contreras, Jun 13, 2021
  7. Ævar Arnfjörð BjarmasonJun 15, 2021
  8. Felipe ContrerasJun 17, 2021
  9. 2/4 merge: fix Yoda conditionsFelipe Contreras, Jun 13, 2021
  10. 3/4 xdiff/xmerge: simplify xdl_recs_copy_0Felipe Contreras, Jun 13, 2021

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.