{"thread":{"id":"32783","subject":"[PATCH 1/3] fixup! mergetool--lib: add functions for finding available tools","startedAt":"2013-01-30T19:55:43Z","lastAt":"2013-01-30T20:34:39Z","messageCount":6,"participants":["John Keeping","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"208309","messageId":"cover.1359575447.git.john@keeping.me.uk","threadId":"32783","inReplyTo":null,"subject":"[PATCH 0/3] mergetool: add user configured commands to '--tool-help'","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2013-01-30T19:55:43Z","receivedAt":"2013-01-30T19:55:43Z","isPatch":true,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"The first couple of these are fixups to da/mergetool-docs.  I think the\nfirst one's obvious, but the second one should possible be changed into\nan incremental patch on top.  I did it this way for now since that patch\nis basically my comments in [1] in patch form.\n\nThe final patch adds tools from git-config to the '--tool-help' output.\n\n[1] http://article.gmane.org/gmane.comp.version-control.git/214964\n\nJohn Keeping (3):\n  fixup! mergetool--lib: add functions for finding available tools\n  fixup!  doc: generate a list of valid merge tools\n  mergetool--lib: list user configured tools in '--tool-help'\n\n git-mergetool--lib.sh | 82 +++++++++++++++++++++++++++++++++++++++------------\n 1 file changed, 63 insertions(+), 19 deletions(-)\n\n-- \n1.8.1.1\n"},{"id":"208305","messageId":"2c7dec096455e6e43d2e9aa28668f69a26f3d5f9.1359575447.git.john@keeping.me.uk","threadId":"32783","inReplyTo":"cover.1359575447.git.john@keeping.me.uk","subject":"[PATCH 1/3] fixup! mergetool--lib: add functions for finding available tools","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2013-01-30T19:55:44Z","receivedAt":"2013-01-30T19:55:44Z","isPatch":true,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"Signed-off-by: John Keeping <john@keeping.me.uk>\n---\n git-mergetool--lib.sh | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh\nindex 25631cd..b6ed2fa 100644\n--- a/git-mergetool--lib.sh\n+++ b/git-mergetool--lib.sh\n@@ -34,9 +34,9 @@ show_tool_names () {\n \t\t\t\tthen\n \t\t\t\t\techo \"$preamble\"\n \t\t\t\t\tpreamble=\n-\t\t\t\t\tshown_any=yes\n \t\t\t\tfi\n-\t\t\t\tprintf \"%s%s\\n\" \"$per_line_prefix\" \"$tool\"\n+\t\t\t\tshown_any=yes\n+\t\t\t\tprintf \"%s%s\\n\" \"$per_line_prefix\" \"$toolname\"\n \t\t\tfi\n \t\tdone\n \t\ttest -n \"$shown_any\"\n@@ -244,6 +244,7 @@ show_tool_help () {\n \n \ttab='\t' av_shown= unav_shown=\n \n+\tcmd_name=${TOOL_MODE}tool\n \tif show_tool_names 'mode_ok && is_available' \"$tab$tab\" \\\n \t\t\"$tool_opt may be set to one of the following:\"\n \tthen\n-- \n1.8.1.1\n"},{"id":"208310","messageId":"ab68c2d04aa2177a303c53517219cff8a82d8db5.1359575447.git.john@keeping.me.uk","threadId":"32783","inReplyTo":"cover.1359575447.git.john@keeping.me.uk","subject":"[PATCH 2/3] fixup! doc: generate a list of valid merge tools","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2013-01-30T19:55:45Z","receivedAt":"2013-01-30T19:55:45Z","isPatch":true,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"Signed-off-by: John Keeping <john@keeping.me.uk>\n---\n git-mergetool--lib.sh | 40 ++++++++++++++++++++++------------------\n 1 file changed, 22 insertions(+), 18 deletions(-)\n\ndiff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh\nindex b6ed2fa..b44a2c8 100644\n--- a/git-mergetool--lib.sh\n+++ b/git-mergetool--lib.sh\n@@ -22,6 +22,7 @@ is_available () {\n \n show_tool_names () {\n \tcondition=${1:-true} per_line_prefix=${2:-} preamble=${3:-}\n+\tnot_found_msg=${4:-}\n \n \tshown_any=\n \t( cd \"$MERGE_TOOLS_DIR\" && ls ) | {\n@@ -32,13 +33,19 @@ show_tool_names () {\n \t\t\tthen\n \t\t\t\tif test -n \"$preamble\"\n \t\t\t\tthen\n-\t\t\t\t\techo \"$preamble\"\n+\t\t\t\t\tprintf \"%s\\n\" \"$preamble\"\n \t\t\t\t\tpreamble=\n \t\t\t\tfi\n \t\t\t\tshown_any=yes\n \t\t\t\tprintf \"%s%s\\n\" \"$per_line_prefix\" \"$toolname\"\n \t\t\tfi\n \t\tdone\n+\n+\t\tif test -n \"$preamble\" && test -n \"$not_found_msg\"\n+\t\tthen\n+\t\t\tprintf \"%s\\n\" \"$not_found_msg\"\n+\t\tfi\n+\n \t\ttest -n \"$shown_any\"\n \t}\n }\n@@ -242,30 +249,27 @@ list_merge_tool_candidates () {\n show_tool_help () {\n \ttool_opt=\"'git ${TOOL_MODE}tool --tool-<tool>'\"\n \n-\ttab='\t' av_shown= unav_shown=\n+\ttab='\t'\n+\tLF='\n+'\n+\tany_shown=no\n \n \tcmd_name=${TOOL_MODE}tool\n-\tif show_tool_names 'mode_ok && is_available' \"$tab$tab\" \\\n-\t\t\"$tool_opt may be set to one of the following:\"\n-\tthen\n-\t\tav_shown=yes\n-\telse\n-\t\techo \"No suitable tool for 'git $cmd_name --tool=<tool>' found.\"\n-\t\tav_shown=no\n-\tfi\n+\tshow_tool_names 'mode_ok && is_available' \"$tab$tab\" \\\n+\t\t\"$tool_opt may be set to one of the following:\" \\\n+\t\t\"No suitable tool for 'git $cmd_name --tool=<tool>' found.\" &&\n+\t\tany_shown=yes\n \n-\tif show_tool_names 'mode_ok && ! is_available' \"$tab$tab\" \\\n-\t\t\"The following tools are valid, but not currently available:\"\n-\tthen\n-\t\tunav_shown=yes\n-\tfi\n+\tshow_tool_names 'mode_ok && ! is_available' \"$tab$tab\" \\\n+\t\t\"${LF}The following tools are valid, but not currently available:\" &&\n+\t\tany_shown=yes\n \n-\tcase \",$av_shown,$unav_shown,\" in\n-\t*,yes,*)\n+\tif test \"$any_shown\" = yes\n+\tthen\n \t\techo\n \t\techo \"Some of the tools listed above only work in a windowed\"\n \t\techo \"environment. If run in a terminal-only session, they will fail.\"\n-\tesac\n+\tfi\n \texit 0\n }\n \n-- \n1.8.1.1\n"},{"id":"208306","messageId":"06855a92e18426f85f205341b6b5afba88e9ef3f.1359575447.git.john@keeping.me.uk","threadId":"32783","inReplyTo":"cover.1359575447.git.john@keeping.me.uk","subject":"[PATCH 3/3] mergetool--lib: list user configured tools in '--tool-help'","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2013-01-30T19:55:46Z","receivedAt":"2013-01-30T19:55:46Z","isPatch":true,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"Signed-off-by: John Keeping <john@keeping.me.uk>\n---\n git-mergetool--lib.sh | 41 ++++++++++++++++++++++++++++++++++++++++-\n 1 file changed, 40 insertions(+), 1 deletion(-)\n\ndiff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh\nindex b44a2c8..e338be5 100644\n--- a/git-mergetool--lib.sh\n+++ b/git-mergetool--lib.sh\n@@ -20,9 +20,24 @@ is_available () {\n \ttype \"$merge_tool_path\" >/dev/null 2>&1\n }\n \n+list_config_tools () {\n+\tsection=$1\n+\tline_prefix=${2:-}\n+\n+\tgit config --get-regexp $section'\\..*\\.cmd' |\n+\twhile read -r key value\n+\tdo\n+\t\ttoolname=${key#$section.}\n+\t\ttoolname=${toolname%.cmd}\n+\n+\t\tprintf \"%s%s\\n\" \"$line_prefix\" \"$toolname\"\n+\tdone\n+}\n+\n show_tool_names () {\n \tcondition=${1:-true} per_line_prefix=${2:-} preamble=${3:-}\n \tnot_found_msg=${4:-}\n+\textra_content=${5:-}\n \n \tshown_any=\n \t( cd \"$MERGE_TOOLS_DIR\" && ls ) | {\n@@ -41,6 +56,19 @@ show_tool_names () {\n \t\t\tfi\n \t\tdone\n \n+\t\tif test -n \"$extra_content\"\n+\t\tthen\n+\t\t\tif test -n \"$preamble\"\n+\t\t\tthen\n+\t\t\t\t# Note: no '\\n' here since we don't want a\n+\t\t\t\t# blank line if there is no initial content.\n+\t\t\t\tprintf \"%s\" \"$preamble\"\n+\t\t\t\tpreamble=\n+\t\t\tfi\n+\t\t\tshown_any=yes\n+\t\t\tprintf \"\\n%s\\n\" \"$extra_content\"\n+\t\tfi\n+\n \t\tif test -n \"$preamble\" && test -n \"$not_found_msg\"\n \t\tthen\n \t\t\tprintf \"%s\\n\" \"$not_found_msg\"\n@@ -255,9 +283,20 @@ show_tool_help () {\n \tany_shown=no\n \n \tcmd_name=${TOOL_MODE}tool\n+\tconfig_tools=$({\n+\t\tdiff_mode && list_config_tools difftool \"$tab$tab\"\n+\t\tlist_config_tools mergetool \"$tab$tab\"\n+\t} | sort)\n+\textra_content=\n+\tif test -n \"$config_tools\"\n+\tthen\n+\t\textra_content=\"${tab}user-defined:${LF}$config_tools\"\n+\tfi\n+\n \tshow_tool_names 'mode_ok && is_available' \"$tab$tab\" \\\n \t\t\"$tool_opt may be set to one of the following:\" \\\n-\t\t\"No suitable tool for 'git $cmd_name --tool=<tool>' found.\" &&\n+\t\t\"No suitable tool for 'git $cmd_name --tool=<tool>' found.\" \\\n+\t\t\"$extra_content\" &&\n \t\tany_shown=yes\n \n \tshow_tool_names 'mode_ok && ! is_available' \"$tab$tab\" \\\n-- \n1.8.1.1\n"},{"id":"208313","messageId":"7vk3quju7t.fsf@alter.siamese.dyndns.org","threadId":"32783","inReplyTo":"2c7dec096455e6e43d2e9aa28668f69a26f3d5f9.1359575447.git.john@keeping.me.uk","subject":"Re: [PATCH 1/3] fixup! mergetool--lib: add functions for finding available tools","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-01-30T20:23:34Z","receivedAt":"2013-01-30T20:23:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"John Keeping <john@keeping.me.uk> writes:\n\n> Signed-off-by: John Keeping <john@keeping.me.uk>\n> ---\n>  git-mergetool--lib.sh | 5 +++--\n>  1 file changed, 3 insertions(+), 2 deletions(-)\n\nThanks.\n\n> diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh\n> index 25631cd..b6ed2fa 100644\n> --- a/git-mergetool--lib.sh\n> +++ b/git-mergetool--lib.sh\n> @@ -34,9 +34,9 @@ show_tool_names () {\n>  \t\t\t\tthen\n>  \t\t\t\t\techo \"$preamble\"\n>  \t\t\t\t\tpreamble=\n> -\t\t\t\t\tshown_any=yes\n>  \t\t\t\tfi\n> -\t\t\t\tprintf \"%s%s\\n\" \"$per_line_prefix\" \"$tool\"\n> +\t\t\t\tshown_any=yes\n> +\t\t\t\tprintf \"%s%s\\n\" \"$per_line_prefix\" \"$toolname\"\n\nThanks for spotting s/tool/toolname/; does the change to shown_any\nmatter, though?\n\n>  \t\t\tfi\n>  \t\tdone\n>  \t\ttest -n \"$shown_any\"\n> @@ -244,6 +244,7 @@ show_tool_help () {\n>  \n>  \ttab='\t' av_shown= unav_shown=\n>  \n> +\tcmd_name=${TOOL_MODE}tool\n>  \tif show_tool_names 'mode_ok && is_available' \"$tab$tab\" \\\n>  \t\t\"$tool_opt may be set to one of the following:\"\n>  \tthen\n"},{"id":"208316","messageId":"20130130203439.GO1342@serenity.lan","threadId":"32783","inReplyTo":"7vk3quju7t.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 1/3] fixup! mergetool--lib: add functions for finding available tools","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2013-01-30T20:34:39Z","receivedAt":"2013-01-30T20:34:39Z","isPatch":true,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"On Wed, Jan 30, 2013 at 12:23:34PM -0800, Junio C Hamano wrote:\n> > diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh\n> > index 25631cd..b6ed2fa 100644\n> > --- a/git-mergetool--lib.sh\n> > +++ b/git-mergetool--lib.sh\n> > @@ -34,9 +34,9 @@ show_tool_names () {\n> >  \t\t\t\tthen\n> >  \t\t\t\t\techo \"$preamble\"\n> >  \t\t\t\t\tpreamble=\n> > -\t\t\t\t\tshown_any=yes\n> >  \t\t\t\tfi\n> > -\t\t\t\tprintf \"%s%s\\n\" \"$per_line_prefix\" \"$tool\"\n> > +\t\t\t\tshown_any=yes\n> > +\t\t\t\tprintf \"%s%s\\n\" \"$per_line_prefix\" \"$toolname\"\n> \n> Thanks for spotting s/tool/toolname/; does the change to shown_any\n> matter, though?\n\nNot really since we don't call it with an empty \"$preamble\" but if\nsomething ever did then this ensures that shown_any is set correctly.\n\nThe $tool -> $toolname doesn't really matter either since setup_tool\nsets it as a global variable, but I'd rather not rely on that.\n\n> >  \t\t\tfi\n> >  \t\tdone\n> >  \t\ttest -n \"$shown_any\"\n> > @@ -244,6 +244,7 @@ show_tool_help () {\n> >  \n> >  \ttab='\t' av_shown= unav_shown=\n> >  \n> > +\tcmd_name=${TOOL_MODE}tool\n> >  \tif show_tool_names 'mode_ok && is_available' \"$tab$tab\" \\\n> >  \t\t\"$tool_opt may be set to one of the following:\"\n> >  \tthen\n"}]}