{"thread":{"id":"39676","subject":"[PATCH] mergetool-lib: fix default tool selection","startedAt":"2015-06-19T09:30:55Z","lastAt":"2015-06-19T17:39:08Z","messageCount":2,"participants":["Michael J Gruber","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"264285","messageId":"a9844fc48424d5caf27cc2189af3d9d867d01833.1434706187.git.git@drmicha.warpmail.net","threadId":"39676","inReplyTo":null,"subject":"[PATCH] mergetool-lib: fix default tool selection","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2015-06-19T09:30:55Z","receivedAt":"2015-06-19T09:30:55Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"When no diff nor merge tool is specified (config, option), mergetool-lib\nis supposed to choose a default tool from a set of tools. That set is\nconstructed dynamically depending on the environment (graphical, editor\nsetting) as a space separated string of tool names.\n\n719518f (mergetool--lib: set IFS for difftool and mergetool, 2015-05-20)\nintroduced a newline as IFS which breaks the parsing of the space\nseparated list into items, resulting in a failed search for an available\ntool.\n\nSet IFS to a space locally for the tool search.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n git-mergetool--lib.sh | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh\nindex 14b039d..54ac8e4 100644\n--- a/git-mergetool--lib.sh\n+++ b/git-mergetool--lib.sh\n@@ -305,6 +305,7 @@ guess_merge_tool () {\n \tEOF\n \n \t# Loop over each candidate and stop when a valid merge tool is found.\n+\tIFS=' '\n \tfor tool in $tools\n \tdo\n \t\tis_available \"$tool\" && echo \"$tool\" && return 0\n-- \n2.4.4.610.gea30ab1.dirty\n"},{"id":"264345","messageId":"xmqqbngba98j.fsf@gitster.dls.corp.google.com","threadId":"39676","inReplyTo":"a9844fc48424d5caf27cc2189af3d9d867d01833.1434706187.git.git@drmicha.warpmail.net","subject":"Re: [PATCH] mergetool-lib: fix default tool selection","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-06-19T17:39:08Z","receivedAt":"2015-06-19T17:39:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n\n> When no diff nor merge tool is specified (config, option), mergetool-lib\n> is supposed to choose a default tool from a set of tools. That set is\n> constructed dynamically depending on the environment (graphical, editor\n> setting) as a space separated string of tool names.\n>\n> 719518f (mergetool--lib: set IFS for difftool and mergetool, 2015-05-20)\n> introduced a newline as IFS which breaks the parsing of the space\n> separated list into items, resulting in a failed search for an available\n> tool.\n>\n> Set IFS to a space locally for the tool search.\n\nI wondered where this \"locally\" is ensured; it turns out that this\nshell function is supposed to be always called inside $() to return\nits result via its standard output ;-)\n\nSo I think this change makes sense.\n\n> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n> ---\n>  git-mergetool--lib.sh | 1 +\n>  1 file changed, 1 insertion(+)\n>\n> diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh\n> index 14b039d..54ac8e4 100644\n> --- a/git-mergetool--lib.sh\n> +++ b/git-mergetool--lib.sh\n> @@ -305,6 +305,7 @@ guess_merge_tool () {\n>  \tEOF\n>  \n>  \t# Loop over each candidate and stop when a valid merge tool is found.\n> +\tIFS=' '\n>  \tfor tool in $tools\n>  \tdo\n>  \t\tis_available \"$tool\" && echo \"$tool\" && return 0\n"}]}