git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: John Keeping <john@keeping.me.uk>
Cc: git@vger.kernel.org, David Aguilar <davvid@gmail.com>
Subject: Re: mergetool: include custom tools in '--tool-help'
Date: Sun, 27 Jan 2013 10:03:19 -0800	[thread overview]
Message-ID: <7vobgawljs.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20130127163442.GQ7498@serenity.lan> (John Keeping's message of "Sun, 27 Jan 2013 16:34:42 +0000")

John Keeping <john@keeping.me.uk> writes:

> 'git mergetool --tool-help' only lists builtin tools, not those that the
> user has configured via a 'mergetool.<tool>.cmd' config value.  Fix this
> by inspecting the tools configured in this way and adding them to the
> available and unavailable lists before displaying them.

Although I am not a mergetool user, I would imagine that it would
make sense to show it as available.

Just like "git help -a" lists subcommands in a way that can be easy
to tell which ones are the standard ones and which ones are user
customizations, this may want to give a similar distinction, though.
I dunno.

>
> Signed-off-by: John Keeping <john@keeping.me.uk>
> ---
> After the recent changes to mergetool, do we want to do something like
> this as well, so that 'git mergetool --tool-help' will display any tools
> configured by the user/system administrator?
>
> This is on top of jk/mergetool.
>
>  git-mergetool--lib.sh | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
>
> diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
> index 1d0fb12..f9a617c 100644
> --- a/git-mergetool--lib.sh
> +++ b/git-mergetool--lib.sh
> @@ -206,6 +206,29 @@ list_merge_tool_candidates () {
>  	esac
>  }
>  
> +# Adds tools from git-config to the available and unavailable lists.
> +# The tools are found in "$1.<tool>.cmd".
> +add_config_tools() {
> +	section=$1
> +
> +	eval $(git config --get-regexp $section'\..*\.cmd' |
> +		while read -r key value
> +		do
> +			tool=${key#mergetool.}
> +			tool=${tool%.cmd}
> +
> +			tool=$(echo "$tool" |sed -e 's/'\''/'\''\\'\'\''/g')
> +
> +			cmd=$(eval -- "set -- $value"; echo "$1")
> +			if type "$cmd" >/dev/null 2>&1
> +			then
> +				echo "available=\"\${available}\"'$tool'\"\$LF\""
> +			else
> +				echo "unavailable=\"\${unavailable}\"'$tool'\"\$LF\""
> +			fi
> +		done)
> +}
> +
>  show_tool_help () {
>  	unavailable= available= LF='
>  '
> @@ -223,6 +246,12 @@ show_tool_help () {
>  		fi
>  	done
>  
> +	add_config_tools mergetool
> +	if diff_mode
> +	then
> +		add_config_tools difftool
> +	fi
> +
>  	cmd_name=${TOOL_MODE}tool
>  	if test -n "$available"
>  	then

  reply	other threads:[~2013-01-27 18:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-27 16:34 mergetool: include custom tools in '--tool-help' John Keeping
2013-01-27 18:03 ` Junio C Hamano [this message]
2013-01-27 19:56   ` John Keeping
2013-01-27 20:13     ` Junio C Hamano
2013-01-27 21:10       ` David Aguilar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vobgawljs.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=davvid@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=john@keeping.me.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).