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

[PATCH] mergetool: do not enable hideResolved by default

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Mar 9, 2021, 02:29 UTC
Message-ID
<YEbdj27CmjNKSWf4@google.com>
In-Reply-To
<20210209200712.156540-2-seth@eseth.com>

A typical mergetool uses four panes, showing the content of the file being resolved from MERGE_BASE ('BASE'), HEAD ('LOCAL'), MERGE_HEAD ('REMOTE'), and the working copy. This allows understanding the conflicts in context: by seeing the entire content of the file from MERGE_HEAD, say, we can see the full intent of the code we are pulling in and understand what they were trying to do that conflicted with our own changes.

Sometimes, though, the exact content of these three competing versions of a file is not so important. Especially if the mergetool supports folding unchanged lines, the new 'mergetool.hideResolved' feature can be helpful for allowing a person resolving a merge to focus on the portion with conflicts. For sections of the file where BASE matched LOCAL or REMOTE, this feature makes all three versions match the resolved version, so that the user resolving can focus exclusively on the portions with conflicts. In other words, hideResolved makes a multi-pane merge tool show a similar amount of information to the file with conflict markers with conflictstyle=diff3, saving the operator from having to pay attention to parts that resolved cleanly.

98ea309b3f (mergetool: add hideResolved configuration, 2021-02-09) which introduced this setting enabled it by default, explaining:

    No adverse effects were noted in a small survey of popular mergetools[1]
    so this behavior defaults to `true`. However it can be globally disabled
    by setting `mergetool.hideResolved` to `false`.

In practice, however, this has proved confusing for users. No indication is shown in the UI that the base, local, and remote versions shown have been modified by additional resolution. Especially in cases where conflicts involve elements beyond textual conflict, it has resulted in incorrect resolutions and wasted work to figure out what happened. Flip the default back to the traditional behavior of `false`: although the old behavior involves slightly slower merges in the only-textual-conflicts case, it prevents this kind of painful moment of betrayal by one's tools, which is more important.

Should we want to migrate to hideResolved=true in the future, we still can. It just requires a more careful migration, including a period where "git mergetool" shows a warning or errors out in affected cases.

Reported-by: Dana Dahlstrom <dahlstrom@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Hi,
Seth House wrote:
> No adverse effects were noted in a small survey of popular mergetools[1]
> so this behavior defaults to `true`. However it can be globally disabled
> by setting `mergetool.hideResolved` to `false`.

Thanks much for protecting this by a flag. We tried this out internally at Google when it hit "next" and not too long later realized that the new default of "true" is not workable for us. I don't believe it's the right default for Git, either, hence this patch.

Thanks for working on the merge resolution workflow; it's much appreciated.

Sincerely, Jonathan

 Documentation/config/mergetool.txt | 2 +-
 git-mergetool.sh                   | 9 ++-------
 2 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/Documentation/config/mergetool.txt b/Documentation/config/mergetool.txt
index 90f76f5b9b..cafbbef46a 100644
--- a/Documentation/config/mergetool.txt
+++ b/Documentation/config/mergetool.txt
@@ -53,7 +53,7 @@ mergetool.hideResolved::
 	resolution. This flag causes 'LOCAL' and 'REMOTE' to be overwriten so
 	that only the unresolved conflicts are presented to the merge tool. Can
 	be configured per-tool via the `mergetool.<tool>.hideResolved`
-	configuration variable. Defaults to `true`.
+	configuration variable. Defaults to `false`.
 
 mergetool.keepBackup::
 	After performing a merge, the original file with conflict markers
diff --git a/git-mergetool.sh b/git-mergetool.sh
index 911470a5b2..f751d9cfe2 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -358,13 +358,8 @@ merge_file () {
 		    enabled=false
 		fi
 	else
-		# The user does not have a preference. Ask the tool.
-		if hide_resolved_enabled
-		then
-		    enabled=true
-		else
-		    enabled=false
-		fi
+		# The user does not have a preference. Default to disabled.
+		enabled=false
 	fi
 
 	if test "$enabled" = true
-- 
2.31.0.rc1.246.gcd05c9c855
Previous: Seth HouseNext: Seth House
Message 62 of 80 in “mergetool: remove unconflicted lines”
  1. 0/1 mergetool: remove unconflicted linesFelipe Contreras, Dec 23, 2020
  2. 1/1 mergetool: add automerge configurationFelipe Contreras, Dec 23, 2020
  3. Junio C HamanoDec 23, 2020
  4. Felipe ContrerasDec 23, 2020
  5. Junio C HamanoDec 23, 2020
  6. Felipe ContrerasDec 24, 2020
  7. Junio C HamanoDec 24, 2020
  8. Felipe ContrerasDec 24, 2020
  9. Junio C HamanoDec 24, 2020
  10. Felipe ContrerasDec 24, 2020
  11. Junio C HamanoDec 24, 2020
  12. Felipe ContrerasDec 27, 2020
  13. Junio C HamanoDec 24, 2020
  14. Felipe ContrerasDec 24, 2020
  15. Johannes SchindelinDec 30, 2020
  16. Felipe ContrerasDec 30, 2020
  17. 0/1 mergetool: add automerge configurationSeth House, Dec 27, 2020
  18. 2/2 mergetool: Add per-tool support for the autoMerge flagSeth House, Dec 27, 2020
  19. Junio C HamanoDec 27, 2020
  20. 1/2 mergetool: add automerge configurationSeth House, Dec 27, 2020
  21. Junio C HamanoDec 27, 2020
  22. Seth HouseDec 27, 2020
  23. Junio C HamanoDec 27, 2020
  24. 0/2 mergetool: add automerge configurationSeth House, Dec 28, 2020
  25. 2/2 mergetool: Add per-tool support for the autoMerge flagSeth House, Dec 28, 2020
  26. Felipe ContrerasDec 28, 2020
  27. 1/2 mergetool: add automerge configurationSeth House, Dec 28, 2020
  28. 0/4 mergetool: add automerge configurationSeth House, Dec 28, 2020
  29. 1/4 mergetool: add automerge configurationSeth House, Dec 28, 2020
  30. Johannes SixtDec 28, 2020
  31. 2/4 mergetool: Add per-tool support for the autoMerge flagSeth House, Dec 28, 2020
  32. Junio C HamanoDec 28, 2020
  33. 4/4 mergetool: Add automerge_enabled tool-specific override functionSeth House, Dec 28, 2020
  34. Johannes SixtDec 28, 2020
  35. Junio C HamanoDec 28, 2020
  36. 3/4 mergetool: Break setup_tool out into separate initialization functionSeth House, Dec 28, 2020
  37. Johannes SixtDec 28, 2020
  38. 0/5 mergetool: add automerge configurationSeth House, Dec 28, 2020
  39. 5/5 mergetool: add automerge_enabled tool-specific override functionSeth House, Dec 28, 2020
  40. Felipe ContrerasDec 29, 2020
  41. Junio C HamanoJan 6, 2021
  42. Seth HouseJan 7, 2021
  43. Junio C HamanoJan 7, 2021
  44. Seth HouseJan 7, 2021
  45. Junio C HamanoJan 7, 2021
  46. Johannes SchindelinJan 8, 2021
  47. 3/5 mergetool: add per-tool support for the autoMerge flagSeth House, Dec 28, 2020
  48. 4/5 mergetool: break setup_tool out into separate initialization functionSeth House, Dec 28, 2020
  49. Johannes SixtDec 29, 2020
  50. Seth HouseDec 29, 2020
  51. 2/5 mergetool: alphabetize the mergetool config docsSeth House, Dec 28, 2020
  52. 1/5 mergetool: add automerge configurationSeth House, Dec 28, 2020
  53. 0/3 mergetool: add hideResolved configuration (was automerge)Seth House, Jan 30, 2021
  54. 3/3 mergetool: add per-tool support and overrides for the hideResolved flagSeth House, Jan 30, 2021
  55. Junio C HamanoJan 30, 2021
  56. 2/3 mergetool: break setup_tool out into separate initialization functionSeth House, Jan 30, 2021
  57. 1/3 mergetool: add hideResolved configurationSeth House, Jan 30, 2021
  58. Junio C HamanoJan 30, 2021
  59. 0/3 mergetool: add hideResolved configuration (was automerge)Seth House, Feb 9, 2021
  60. 2/3 mergetool: break setup_tool out into separate initialization functionSeth House, Feb 9, 2021
  61. 1/3 mergetool: add hideResolved configurationSeth House, Feb 9, 2021
  62. mergetool: do not enable hideResolved by defaultJonathan Nieder, Mar 9, 2021
  63. Seth HouseMar 9, 2021
  64. Jonathan NiederMar 10, 2021
  65. Junio C HamanoMar 10, 2021
  66. Junio C HamanoMar 11, 2021
  67. Junio C HamanoMar 12, 2021
  68. Jonathan NiederMar 12, 2021
  69. Junio C HamanoMar 12, 2021
  70. 0/2 mergetool: do not enable hideResolved by defaultJonathan Nieder, Mar 13, 2021
  71. 1/2 mergetool: do not enable hideResolved by defaultJonathan Nieder, Mar 13, 2021
  72. 2/2 doc: describe mergetool configuration in git-mergetool(1)Jonathan Nieder, Mar 13, 2021
  73. Junio C HamanoMar 13, 2021
  74. Junio C HamanoMar 13, 2021
  75. 3/3 mergetool: add per-tool support and overrides for the hideResolved flagSeth House, Feb 9, 2021
  76. Junio C HamanoFeb 9, 2021
  77. Seth HouseFeb 9, 2021
  78. Junio C HamanoDec 28, 2020
  79. Felipe ContrerasDec 28, 2020
  80. Felipe ContrerasDec 28, 2020

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.