mergetool: break setup_tool out into separate initialization function

This is preparation for the following commit where we need to source the
mergetool shell script to look for overrides before `run_merge_tool` is
called. Previously `run_merge_tool` both sourced that script and invoked
the mergetool.

In the case of the following commit, we need the result of the
`hide_resolved` override, if present, before we actually run
`run_merge_tool`.

The new `initialize_merge_tool` wrapper is exposed and documented as
a public interface for consistency with the existing `run_merge_tool`
which is also public. Although `setup_tool` could instead be exposed
directly, the related `setup_user_tool` would probably also want to be
elevated to match and this felt the cleanest to me.

Signed-off-by: Seth House <seth@eseth.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Seth House
2021-02-09 13:07:11 -07:00
committed by Junio C Hamano
parent 98ea309b3f
commit de8dafbada
4 changed files with 16 additions and 3 deletions

View File

@@ -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
if merge_mode
then
run_merge_cmd "$1"