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

[PATCH] diff: prefer indent heuristic over compaction heuristic

From
Jacob Keller <jacob.e.keller@intel.com>
Date
Dec 17, 2016, 00:54 UTC
Message-ID
<20161217005442.5866-1-jacob.e.keller@intel.com>
From: Jacob Keller <jacob.keller@gmail.com>

The current configuration code for enabling experimental heuristics prefers the last-set heuristic in the configuration. However, it is not necessarily easy to see what order the configuration will be read. This means that it is possible for a user to have accidentally enabled both heuristics, and end up only enabling the older compaction heuristic.

Modify the code so that we do not clear the other heuristic when we set each heuristic enabled. Then, during diff_setup() when we check the configuration, we will first check the newer indent heuristic. This ensures that we only enable the newer heuristic if both have been enabled.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
---
 diff.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/diff.c b/diff.c
index ec8728362dae..48a5b2797e3d 100644
--- a/diff.c
+++ b/diff.c
@@ -223,16 +223,10 @@ void init_diff_ui_defaults(void)
 
 int git_diff_heuristic_config(const char *var, const char *value, void *cb)
 {
-	if (!strcmp(var, "diff.indentheuristic")) {
+	if (!strcmp(var, "diff.indentheuristic"))
 		diff_indent_heuristic = git_config_bool(var, value);
-		if (diff_indent_heuristic)
-			diff_compaction_heuristic = 0;
-	}
-	if (!strcmp(var, "diff.compactionheuristic")) {
+	if (!strcmp(var, "diff.compactionheuristic"))
 		diff_compaction_heuristic = git_config_bool(var, value);
-		if (diff_compaction_heuristic)
-			diff_indent_heuristic = 0;
-	}
 	return 0;
 }
 
-- 
2.11.0.rc2.152.g4d04e67
Next: Junio C Hamano
Message 1 of 17 in “diff: prefer indent heuristic over compaction heuristic”
  1. diff: prefer indent heuristic over compaction heuristicJacob Keller, Dec 17, 2016
  2. Junio C HamanoDec 17, 2016
  3. Jacob KellerDec 17, 2016
  4. Junio C HamanoDec 22, 2016
  5. Jacob KellerDec 22, 2016
  6. Junio C HamanoDec 22, 2016
  7. Jeff KingDec 23, 2016
  8. Jacob KellerDec 23, 2016
  9. Jeff KingDec 23, 2016
  10. Junio C HamanoDec 23, 2016
  11. Junio C HamanoDec 23, 2016
  12. Jeff KingDec 23, 2016
  13. Jacob KellerDec 23, 2016
  14. Michael HaggertyDec 24, 2016
  15. Stefan BellerApr 27, 2017
  16. Jeff KingApr 28, 2017
  17. Martin LiškaApr 28, 2017

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.