diff options
author | David Aguilar <davvid@gmail.com> | 2009-03-09 02:12:36 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-03-11 21:54:59 -0700 |
commit | 2464456a6ac9216d59d9e2cf0d86fee072f63cf8 (patch) | |
tree | 39211d813d41105b2d3079df9238811da162c254 /contrib/difftool/git-difftool-helper | |
parent | Update release notes to 1.6.3 (diff) | |
download | tgif-2464456a6ac9216d59d9e2cf0d86fee072f63cf8.tar.xz |
contrib/difftool: use a separate config namespace for difftool commands
Some users have different mergetool and difftool settings, so teach
difftool to read config vars from the difftool.* namespace. This allows
having distinct configurations for the diff and merge scenarios.
We don't want to force existing users to set new values for no reason
so difftool falls back to existing mergetool config variables when the
difftool equivalents are not defined.
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/difftool/git-difftool-helper')
-rwxr-xr-x | contrib/difftool/git-difftool-helper | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/contrib/difftool/git-difftool-helper b/contrib/difftool/git-difftool-helper index db3af6a833..9c0a13452a 100755 --- a/contrib/difftool/git-difftool-helper +++ b/contrib/difftool/git-difftool-helper @@ -128,8 +128,10 @@ launch_merge_tool () { cleanup_temp_files } -# Verifies that mergetool.<tool>.cmd exists +# Verifies that (difftool|mergetool).<tool>.cmd exists valid_custom_tool() { + merge_tool_cmd="$(git config difftool.$1.cmd)" + test -z "$merge_tool_cmd" && merge_tool_cmd="$(git config mergetool.$1.cmd)" test -n "$merge_tool_cmd" } @@ -150,8 +152,11 @@ valid_tool() { } # Sets up the merge_tool_path variable. -# This handles the mergetool.<tool>.path configuration. +# This handles the difftool.<tool>.path configuration. +# This also falls back to mergetool defaults. init_merge_tool_path() { + merge_tool_path=$(git config difftool."$1".path) + test -z "$merge_tool_path" && merge_tool_path=$(git config mergetool."$1".path) if test -z "$merge_tool_path"; then case "$1" in @@ -165,15 +170,19 @@ init_merge_tool_path() { fi } -# Allow the GIT_MERGE_TOOL variable to provide a default value +# Allow GIT_DIFF_TOOL and GIT_MERGE_TOOL to provide default values test -n "$GIT_MERGE_TOOL" && merge_tool="$GIT_MERGE_TOOL" +test -n "$GIT_DIFF_TOOL" && merge_tool="$GIT_DIFF_TOOL" -# If not merge tool was specified then use the merge.tool +# If merge tool was not specified then use the diff.tool # configuration variable. If that's invalid then reset merge_tool. +# Fallback to merge.tool. if test -z "$merge_tool"; then + merge_tool=$(git config diff.tool) + test -z "$merge_tool" && merge_tool=$(git config merge.tool) if test -n "$merge_tool" && ! valid_tool "$merge_tool"; then - echo >&2 "git config option merge.tool set to unknown tool: $merge_tool" + echo >&2 "git config option diff.tool set to unknown tool: $merge_tool" echo >&2 "Resetting to default..." unset merge_tool fi |