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

Re: [PATCH v8 3/4] mergetool: Break setup_tool out into separate initialization function

From
Johannes Sixt <j6t@kdbg.org>
Date
Dec 28, 2020, 11:48 UTC
Message-ID
<cc8c5d6e-eee3-afdb-55cc-633455a5dcfa@kdbg.org>
In-Reply-To
<20201228045427.1166911-4-seth@eseth.com>
Am 28.12.20 um 05:54 schrieb Seth House:
> The tool-specific functions are sometimes needed in scope earlier than
> when run_merge_tool is called.

You should answer why this change is needed. "are sometimes needed in scope earlier" cannot be true, else we would have a bug that is fixed by this change. But this isn't a bug fix, is it?

It would be ok to say "We are going to add another thing that we will need before run_merge_tool; this is a preparation" or something.

Which brings me to another point: I do not see that something is added to initialize_merge_tool in a later patch. You are only replacing setup_tool calls by initialize_merge_tool, which forwards to setup_tool. Why do we need a new function?

Show 24 quoted lines
> 
> Signed-off-by: Seth House <seth@eseth.com>
> ---
>  Documentation/git-mergetool--lib.txt | 4 ++++
>  git-difftool--helper.sh              | 2 ++
>  git-mergetool--lib.sh                | 7 ++++---
>  git-mergetool.sh                     | 2 ++
>  4 files changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/git-mergetool--lib.txt b/Documentation/git-mergetool--lib.txt
> index 4da9d24096..3e8f59ac0e 100644
> --- a/Documentation/git-mergetool--lib.txt
> +++ b/Documentation/git-mergetool--lib.txt
> @@ -38,6 +38,10 @@ get_merge_tool_cmd::
>  get_merge_tool_path::
>  	returns the custom path for a merge tool.
>  
> +initialize_merge_tool::
> +	bring merge tool specific functions into scope so they can be used or
> +	overridden.
> +
>  run_merge_tool::
>  	launches a merge tool given the tool name and a true/false
>  	flag to indicate whether a merge base is present.
[ swapped hunks for better sentence structure ]
Show 22 quoted lines
> diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
> index 7225abd811..e059b3559e 100644
> --- a/git-mergetool--lib.sh
> +++ b/git-mergetool--lib.sh
> @@ -248,6 +248,10 @@ trust_exit_code () {
>  	fi
>  }
>
> +initialize_merge_tool () {
> +	# Bring tool-specific functions into scope
> +	setup_tool "$1" || return 1
> +}
>
>  # Entry point for running tools
>  run_merge_tool () {
> @@ -259,9 +263,6 @@ run_merge_tool () {
>  	merge_tool_path=$(get_merge_tool_path "$1") || exit
>  	base_present="$2"
>
> -	# Bring tool-specific functions into scope
> -	setup_tool "$1" || return 1
> -

Before this change, run_merge_tool would exit here when there was an error during setup_tool. But...

Show 11 quoted lines
> diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh
> index 46af3e60b7..c47a6d4253 100755
> --- a/git-difftool--helper.sh
> +++ b/git-difftool--helper.sh
> @@ -61,6 +61,7 @@ launch_merge_tool () {
>  		export BASE
>  		eval $GIT_DIFFTOOL_EXTCMD '"$LOCAL"' '"$REMOTE"'
>  	else
> +		initialize_merge_tool "$merge_tool"
>  		run_merge_tool "$merge_tool"
>  	fi
... after the change we do not exit anymore. Does it matter?
Perhaps
		initialize_merge_tool "$merge_tool" &&
  		run_merge_tool "$merge_tool"
Show 9 quoted lines
>  }
> @@ -79,6 +80,7 @@ if test -n "$GIT_DIFFTOOL_DIRDIFF"
>  then
>  	LOCAL="$1"
>  	REMOTE="$2"
> +	initialize_merge_tool "$merge_tool"
>  	run_merge_tool "$merge_tool" false
>  else
>  	# Launch the merge tool on each path provided by 'git diff'
Show 14 quoted lines
> diff --git a/git-mergetool.sh b/git-mergetool.sh
> index e3c7d78d1d..929192d0f8 100755
> --- a/git-mergetool.sh
> +++ b/git-mergetool.sh
> @@ -334,6 +334,8 @@ merge_file () {
>  	checkout_staged_file 2 "$MERGED" "$LOCAL"
>  	checkout_staged_file 3 "$MERGED" "$REMOTE"
>  
> +	initialize_merge_tool "$merge_tool"
> +
>  	if test "$(
>  		git config --get --bool "mergetool.$merge_tool.automerge" ||
>  		git config --get --bool "mergetool.automerge" ||
> 
Previous: Seth HouseNext: Seth House
Message 37 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.