{"thread":{"id":"32745","subject":"mergetool: include custom tools in '--tool-help'","startedAt":"2013-01-27T16:34:42Z","lastAt":"2013-01-27T21:10:51Z","messageCount":5,"participants":["John Keeping","Junio C Hamano","David Aguilar"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"207961","messageId":"20130127163442.GQ7498@serenity.lan","threadId":"32745","inReplyTo":null,"subject":"mergetool: include custom tools in '--tool-help'","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2013-01-27T16:34:42Z","receivedAt":"2013-01-27T16:34:42Z","isPatch":false,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"'git mergetool --tool-help' only lists builtin tools, not those that the\nuser has configured via a 'mergetool.<tool>.cmd' config value.  Fix this\nby inspecting the tools configured in this way and adding them to the\navailable and unavailable lists before displaying them.\n\nSigned-off-by: John Keeping <john@keeping.me.uk>\n---\nAfter the recent changes to mergetool, do we want to do something like\nthis as well, so that 'git mergetool --tool-help' will display any tools\nconfigured by the user/system administrator?\n\nThis is on top of jk/mergetool.\n\n git-mergetool--lib.sh | 29 +++++++++++++++++++++++++++++\n 1 file changed, 29 insertions(+)\n\ndiff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh\nindex 1d0fb12..f9a617c 100644\n--- a/git-mergetool--lib.sh\n+++ b/git-mergetool--lib.sh\n@@ -206,6 +206,29 @@ list_merge_tool_candidates () {\n \tesac\n }\n \n+# Adds tools from git-config to the available and unavailable lists.\n+# The tools are found in \"$1.<tool>.cmd\".\n+add_config_tools() {\n+\tsection=$1\n+\n+\teval $(git config --get-regexp $section'\\..*\\.cmd' |\n+\t\twhile read -r key value\n+\t\tdo\n+\t\t\ttool=${key#mergetool.}\n+\t\t\ttool=${tool%.cmd}\n+\n+\t\t\ttool=$(echo \"$tool\" |sed -e 's/'\\''/'\\''\\\\'\\'\\''/g')\n+\n+\t\t\tcmd=$(eval -- \"set -- $value\"; echo \"$1\")\n+\t\t\tif type \"$cmd\" >/dev/null 2>&1\n+\t\t\tthen\n+\t\t\t\techo \"available=\\\"\\${available}\\\"'$tool'\\\"\\$LF\\\"\"\n+\t\t\telse\n+\t\t\t\techo \"unavailable=\\\"\\${unavailable}\\\"'$tool'\\\"\\$LF\\\"\"\n+\t\t\tfi\n+\t\tdone)\n+}\n+\n show_tool_help () {\n \tunavailable= available= LF='\n '\n@@ -223,6 +246,12 @@ show_tool_help () {\n \t\tfi\n \tdone\n \n+\tadd_config_tools mergetool\n+\tif diff_mode\n+\tthen\n+\t\tadd_config_tools difftool\n+\tfi\n+\n \tcmd_name=${TOOL_MODE}tool\n \tif test -n \"$available\"\n \tthen\n-- \n1.8.1.1\n"},{"id":"207966","messageId":"7vobgawljs.fsf@alter.siamese.dyndns.org","threadId":"32745","inReplyTo":"20130127163442.GQ7498@serenity.lan","subject":"Re: mergetool: include custom tools in '--tool-help'","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-01-27T18:03:19Z","receivedAt":"2013-01-27T18:03:19Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"John Keeping <john@keeping.me.uk> writes:\n\n> 'git mergetool --tool-help' only lists builtin tools, not those that the\n> user has configured via a 'mergetool.<tool>.cmd' config value.  Fix this\n> by inspecting the tools configured in this way and adding them to the\n> available and unavailable lists before displaying them.\n\nAlthough I am not a mergetool user, I would imagine that it would\nmake sense to show it as available.\n\nJust like \"git help -a\" lists subcommands in a way that can be easy\nto tell which ones are the standard ones and which ones are user\ncustomizations, this may want to give a similar distinction, though.\nI dunno.\n\n>\n> Signed-off-by: John Keeping <john@keeping.me.uk>\n> ---\n> After the recent changes to mergetool, do we want to do something like\n> this as well, so that 'git mergetool --tool-help' will display any tools\n> configured by the user/system administrator?\n>\n> This is on top of jk/mergetool.\n>\n>  git-mergetool--lib.sh | 29 +++++++++++++++++++++++++++++\n>  1 file changed, 29 insertions(+)\n>\n> diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh\n> index 1d0fb12..f9a617c 100644\n> --- a/git-mergetool--lib.sh\n> +++ b/git-mergetool--lib.sh\n> @@ -206,6 +206,29 @@ list_merge_tool_candidates () {\n>  \tesac\n>  }\n>  \n> +# Adds tools from git-config to the available and unavailable lists.\n> +# The tools are found in \"$1.<tool>.cmd\".\n> +add_config_tools() {\n> +\tsection=$1\n> +\n> +\teval $(git config --get-regexp $section'\\..*\\.cmd' |\n> +\t\twhile read -r key value\n> +\t\tdo\n> +\t\t\ttool=${key#mergetool.}\n> +\t\t\ttool=${tool%.cmd}\n> +\n> +\t\t\ttool=$(echo \"$tool\" |sed -e 's/'\\''/'\\''\\\\'\\'\\''/g')\n> +\n> +\t\t\tcmd=$(eval -- \"set -- $value\"; echo \"$1\")\n> +\t\t\tif type \"$cmd\" >/dev/null 2>&1\n> +\t\t\tthen\n> +\t\t\t\techo \"available=\\\"\\${available}\\\"'$tool'\\\"\\$LF\\\"\"\n> +\t\t\telse\n> +\t\t\t\techo \"unavailable=\\\"\\${unavailable}\\\"'$tool'\\\"\\$LF\\\"\"\n> +\t\t\tfi\n> +\t\tdone)\n> +}\n> +\n>  show_tool_help () {\n>  \tunavailable= available= LF='\n>  '\n> @@ -223,6 +246,12 @@ show_tool_help () {\n>  \t\tfi\n>  \tdone\n>  \n> +\tadd_config_tools mergetool\n> +\tif diff_mode\n> +\tthen\n> +\t\tadd_config_tools difftool\n> +\tfi\n> +\n>  \tcmd_name=${TOOL_MODE}tool\n>  \tif test -n \"$available\"\n>  \tthen\n"},{"id":"207975","messageId":"20130127195618.GS7498@serenity.lan","threadId":"32745","inReplyTo":"7vobgawljs.fsf@alter.siamese.dyndns.org","subject":"Re: mergetool: include custom tools in '--tool-help'","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2013-01-27T19:56:18Z","receivedAt":"2013-01-27T19:56:18Z","isPatch":false,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"On Sun, Jan 27, 2013 at 10:03:19AM -0800, Junio C Hamano wrote:\n> John Keeping <john@keeping.me.uk> writes:\n> \n> > 'git mergetool --tool-help' only lists builtin tools, not those that the\n> > user has configured via a 'mergetool.<tool>.cmd' config value.  Fix this\n> > by inspecting the tools configured in this way and adding them to the\n> > available and unavailable lists before displaying them.\n> \n> Although I am not a mergetool user, I would imagine that it would\n> make sense to show it as available.\n> \n> Just like \"git help -a\" lists subcommands in a way that can be easy\n> to tell which ones are the standard ones and which ones are user\n> customizations, this may want to give a similar distinction, though.\n> I dunno.\n\nI think I'd want to do this with a suffix if at all, so the output would\nbe like this:\n\n    'git mergetool --tool=<tool>' may be set to one of the following:\n\n            araxis\n            gvimdiff\n            gvimdiff2\n            mytool\t(user-defined)\n            vimdiff\n            vimdiff2\n\n    The following tools are valid, but not currently available:\n\n            bc3\n            codecompare\n            deltawalker\n            diffuse\n            ecmerge\n            emerge\n            kdiff3\n            meld\n            opendiff\n            p4merge\n            tkdiff\n            tortoisemerge\n            xxdiff\n\n    Some of the tools listed above only work in a windowed\n    environment. If run in a terminal-only session, they will fail.\n\n\nAdding more sections for the user-defined tools feels like the output\nwould be too imposing and would make it hard to immediately identify the\nvalid option.\n\n\nJohn\n"},{"id":"207979","messageId":"7vmwvuv0ya.fsf@alter.siamese.dyndns.org","threadId":"32745","inReplyTo":"20130127195618.GS7498@serenity.lan","subject":"Re: mergetool: include custom tools in '--tool-help'","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-01-27T20:13:33Z","receivedAt":"2013-01-27T20:13:33Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"John Keeping <john@keeping.me.uk> writes:\n\n> I think I'd want to do this with a suffix if at all, so the output would\n> be like this:\n>\n>     'git mergetool --tool=<tool>' may be set to one of the following:\n>\n>             araxis\n>             gvimdiff\n>             gvimdiff2\n>             mytool\t(user-defined)\n>             vimdiff\n>             vimdiff2\n\nThat is fine by me, but the real users of mergetool please feel free\nto raise objections.\n"},{"id":"207985","messageId":"CAJDDKr5s=XS1m2rvBhibwEc8KNJswPJhb1arY0nhf4vZO56z6g@mail.gmail.com","threadId":"32745","inReplyTo":"7vmwvuv0ya.fsf@alter.siamese.dyndns.org","subject":"Re: mergetool: include custom tools in '--tool-help'","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2013-01-27T21:10:51Z","receivedAt":"2013-01-27T21:10:51Z","isPatch":false,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Sun, Jan 27, 2013 at 12:13 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> John Keeping <john@keeping.me.uk> writes:\n>\n>> I think I'd want to do this with a suffix if at all, so the output would\n>> be like this:\n>>\n>>     'git mergetool --tool=<tool>' may be set to one of the following:\n>>\n>>             araxis\n>>             gvimdiff\n>>             gvimdiff2\n>>             mytool    (user-defined)\n>>             vimdiff\n>>             vimdiff2\n>\n> That is fine by me, but the real users of mergetool please feel free\n> to raise objections.\n\nThis seems pretty useful.\n\nI did a bit of refactoring last night that I'd like to post here,\nthe end result being something that's plugged into Documentation/.\n\nI think what I did may also help add this functionality, and\ncould be useful to build upon.\n\nI'll send my patches shortly so you can take a look.\nBasically, I added a simple way to loop over the tools\nand filter them.  This is reused in show_tool_help() and\nDocumentation/Makefile.\n\nThe refactoring changes how show_tool_help() works,\nso I'd like you to take a look before we add a new feature\nsince it might make it easier to do.\n-- \nDavid\n"}]}