{"thread":{"id":"53430","subject":"[PATCH] Enable auto-merge for meld to follow the vim-diff beharior","startedAt":"2020-05-08T01:25:28Z","lastAt":"2020-09-15T00:55:28Z","messageCount":74,"participants":["sunlin via GitGitGadget","Pratyush Yadav","Git Gadget","Junio C Hamano","David Aguilar","lin.sun@zoom.us","Đoàn Trần Công Danh","Lin Sun"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"397388","messageId":"pull.781.git.git.1588901124066.gitgitgadget@gmail.com","threadId":"53430","inReplyTo":null,"subject":"[PATCH] Enable auto-merge for meld to follow the vim-diff beharior","fromName":"sunlin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-05-08T01:25:23Z","receivedAt":"2020-05-08T01:25:28Z","isPatch":true,"sender":{"key":"name:sunlin","avatar":null},"body":"From: \"lin.sun\" <lin.sun@zoom.us>\n\nThe mergetool \"meld\" does NOT merge the no-conflict changes, while the\nmergetool \"vimdiff\" will merge the no-conflict parts and highlight the\nconflict parts.\nThis patch will make the mergetool \"meld\" similar to \"vimdiff\",\nauto-merge the no-conflict parts, highlight conflict parts.\n\nSigned-off-by: Lin Sun <sunlin7@yahoo.com>\n---\n    Enable auto-merge for meld to follow the vimdiff beharior\n    \n    Hi, the mergetool \"meld\" does NOT merge the no-conflict changes, while\n    the mergetool \"vimdiff\" will merge the no-conflict changes and highlight\n    the conflict parts. This patch will make the mergetool \"meld\" similar to\n    \"vimdiff\", auto-merge the no-conflict changes, highlight conflict parts.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-781%2Fsunlin7%2Fmaster-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-781/sunlin7/master-v1\nPull-Request: https://github.com/git/git/pull/781\n\n mergetools/meld | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/mergetools/meld b/mergetools/meld\nindex 7a08470f883..318653cc9f7 100644\n--- a/mergetools/meld\n+++ b/mergetools/meld\n@@ -10,10 +10,10 @@ merge_cmd () {\n \n \tif test \"$meld_has_output_option\" = true\n \tthen\n-\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n+\t\t\"$merge_tool_path\" --auto-merge --output=\"$MERGED\" \\\n \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \telse\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" --auto-merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \tfi\n }\n \n\nbase-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n-- \ngitgitgadget\n"},{"id":"399287","messageId":"20200608094951.pu2fz3kxaj37tk46@yadavpratyush.com","threadId":"53430","inReplyTo":"pull.781.git.git.1588901124066.gitgitgadget@gmail.com","subject":"Re: [PATCH] Enable auto-merge for meld to follow the vim-diff beharior","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2020-06-08T09:49:51Z","receivedAt":"2020-06-08T09:50:01Z","isPatch":true,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"Hi Lin,\n\nI'm not familiar with the code so I'll let someone else comment on that. \nBut...\n\nOn 08/05/20 01:25AM, sunlin via GitGitGadget wrote:\n> From: \"lin.sun\" <lin.sun@zoom.us>\n> \n> The mergetool \"meld\" does NOT merge the no-conflict changes, while the\n> mergetool \"vimdiff\" will merge the no-conflict parts and highlight the\n> conflict parts.\n> This patch will make the mergetool \"meld\" similar to \"vimdiff\",\n> auto-merge the no-conflict parts, highlight conflict parts.\n> \n> Signed-off-by: Lin Sun <sunlin7@yahoo.com>\n\n... your name and email in \"From:\" and \"Signed-off-by:\" should be the \nsame. So either use \"lin.sun\" <lin.sun@zoom.us> in both places or use \nLin Sun <sunlin7@yahoo.com> in both.\n\n-- \nRegards,\nPratyush Yadav\n"},{"id":"399337","messageId":"pull.781.v2.git.git.1591672753363.gitgitgadget@gmail.com","threadId":"53430","inReplyTo":"pull.781.git.git.1588901124066.gitgitgadget@gmail.com","subject":"[PATCH v2] Enable auto-merge for meld to follow the vim-diff beharior","fromName":"sunlin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-06-09T03:19:12Z","receivedAt":"2020-06-09T03:19:19Z","isPatch":true,"sender":{"key":"name:sunlin","avatar":null},"body":"From: \"lin.sun\" <lin.sun@zoom.us>\n\nThe mergetool \"meld\" does NOT merge the no-conflict changes, while the\nmergetool \"vimdiff\" will merge the no-conflict parts and highlight the\nconflict parts.\nThis patch will make the mergetool \"meld\" similar to \"vimdiff\",\nauto-merge the no-conflict parts, highlight conflict parts.\n\nSigned-off-by: Lin Sun <lin.sun@zoom.us>\n---\n    Enable auto-merge for meld to follow the vimdiff beharior\n    \n    Hi, the mergetool \"meld\" does NOT merge the no-conflict changes, while\n    the mergetool \"vimdiff\" will merge the no-conflict changes and highlight\n    the conflict parts. This patch will make the mergetool \"meld\" similar to\n    \"vimdiff\", auto-merge the no-conflict changes, highlight conflict parts.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-781%2Fsunlin7%2Fmaster-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-781/sunlin7/master-v2\nPull-Request: https://github.com/git/git/pull/781\n\nRange-diff vs v1:\n\n 1:  739e69e6631 ! 1:  6e98a10bfa9 Enable auto-merge for meld to follow the vim-diff beharior\n     @@ Commit message\n          This patch will make the mergetool \"meld\" similar to \"vimdiff\",\n          auto-merge the no-conflict parts, highlight conflict parts.\n      \n     -    Signed-off-by: Lin Sun <sunlin7@yahoo.com>\n     +    Signed-off-by: Lin Sun <lin.sun@zoom.us>\n      \n       ## mergetools/meld ##\n      @@ mergetools/meld: merge_cmd () {\n\n\n mergetools/meld | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/mergetools/meld b/mergetools/meld\nindex 7a08470f883..318653cc9f7 100644\n--- a/mergetools/meld\n+++ b/mergetools/meld\n@@ -10,10 +10,10 @@ merge_cmd () {\n \n \tif test \"$meld_has_output_option\" = true\n \tthen\n-\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n+\t\t\"$merge_tool_path\" --auto-merge --output=\"$MERGED\" \\\n \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \telse\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" --auto-merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \tfi\n }\n \n\nbase-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n-- \ngitgitgadget\n"},{"id":"400763","messageId":"pull.781.v3.git.git.1593414441313.gitgitgadget@gmail.com","threadId":"53430","inReplyTo":"pull.781.v2.git.git.1591672753363.gitgitgadget@gmail.com","subject":"[PATCH v3] Enable auto-merge for meld to follow the vim-diff beharior","fromName":"sunlin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-06-29T07:07:21Z","receivedAt":"2020-06-29T20:41:46Z","isPatch":true,"sender":{"key":"name:sunlin","avatar":null},"body":"From: \"lin.sun\" <lin.sun@zoom.us>\n\nThe mergetool \"meld\" does NOT merge the no-conflict changes, while the\nmergetool \"vimdiff\" will merge the no-conflict parts and highlight the\nconflict parts.\nThis patch will make the mergetool \"meld\" similar to \"vimdiff\",\nauto-merge the no-conflict parts, highlight conflict parts.\n\nSigned-off-by: Lin Sun <lin.sun@zoom.us>\n---\n    Enable auto-merge for meld to follow the vimdiff beharior\n    \n    Hi, the mergetool \"meld\" does NOT merge the no-conflict changes, while\n    the mergetool \"vimdiff\" will merge the no-conflict changes and highlight\n    the conflict parts. This patch will make the mergetool \"meld\" similar to\n    \"vimdiff\", auto-merge the no-conflict changes, highlight conflict parts.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-781%2Fsunlin7%2Fmaster-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-781/sunlin7/master-v3\nPull-Request: https://github.com/git/git/pull/781\n\nRange-diff vs v2:\n\n 1:  6e98a10bfa ! 1:  3b70fd0bfc Enable auto-merge for meld to follow the vim-diff beharior\n     @@ Commit message\n      \n       ## mergetools/meld ##\n      @@ mergetools/meld: merge_cmd () {\n     + \tthen\n     + \t\tcheck_meld_for_output_version\n     + \tfi\n     ++\tif test -z \"${meld_has_auto_merge_option:+set}\"\n     ++\tthen\n     ++\t\tcheck_meld_for_auto_merge_version\n     ++\tfi\n     ++\n     ++\toption_auto_merge=\n     ++\tif test \"$meld_has_auto_merge_option\" = true\n     ++\tthen\n     ++\t\toption_auto_merge=\"--auto-merge\"\n     ++\tfi\n       \n       \tif test \"$meld_has_output_option\" = true\n       \tthen\n      -\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n     -+\t\t\"$merge_tool_path\" --auto-merge --output=\"$MERGED\" \\\n     ++\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n       \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n       \telse\n      -\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n     -+\t\t\"$merge_tool_path\" --auto-merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n     ++\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n       \tfi\n       }\n       \n     +@@ mergetools/meld: check_meld_for_output_version () {\n     + \t\tmeld_has_output_option=false\n     + \tfi\n     + }\n     ++\n     ++# Check whether we should use 'meld --auto-merge ...'\n     ++check_meld_for_auto_merge_version () {\n     ++\tmeld_path=\"$(git config mergetool.meld.path)\"\n     ++\tmeld_path=\"${meld_path:-meld}\"\n     ++\n     ++\tif meld_has_auto_merge_option=$(git config --bool mergetool.meld.hasAutoMerge)\n     ++\tthen\n     ++\t\t: use configured value\n     ++\telif \"$meld_path\" --help 2>&1 |\n     ++\t\tgrep -e '--auto-merge' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n     ++\tthen\n     ++\t\t: old ones mention --auto-merge and new ones just say OPTION...\n     ++\t\tmeld_has_auto_merge_option=true\n     ++\telse\n     ++\t\tmeld_has_auto_merge_option=false\n     ++\tfi\n     ++}\n\n\n mergetools/meld | 32 ++++++++++++++++++++++++++++++--\n 1 file changed, 30 insertions(+), 2 deletions(-)\n\ndiff --git a/mergetools/meld b/mergetools/meld\nindex 7a08470f88..91b65ff22c 100644\n--- a/mergetools/meld\n+++ b/mergetools/meld\n@@ -7,13 +7,23 @@ merge_cmd () {\n \tthen\n \t\tcheck_meld_for_output_version\n \tfi\n+\tif test -z \"${meld_has_auto_merge_option:+set}\"\n+\tthen\n+\t\tcheck_meld_for_auto_merge_version\n+\tfi\n+\n+\toption_auto_merge=\n+\tif test \"$meld_has_auto_merge_option\" = true\n+\tthen\n+\t\toption_auto_merge=\"--auto-merge\"\n+\tfi\n \n \tif test \"$meld_has_output_option\" = true\n \tthen\n-\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n+\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \telse\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \tfi\n }\n \n@@ -34,3 +44,21 @@ check_meld_for_output_version () {\n \t\tmeld_has_output_option=false\n \tfi\n }\n+\n+# Check whether we should use 'meld --auto-merge ...'\n+check_meld_for_auto_merge_version () {\n+\tmeld_path=\"$(git config mergetool.meld.path)\"\n+\tmeld_path=\"${meld_path:-meld}\"\n+\n+\tif meld_has_auto_merge_option=$(git config --bool mergetool.meld.hasAutoMerge)\n+\tthen\n+\t\t: use configured value\n+\telif \"$meld_path\" --help 2>&1 |\n+\t\tgrep -e '--auto-merge' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n+\tthen\n+\t\t: old ones mention --auto-merge and new ones just say OPTION...\n+\t\tmeld_has_auto_merge_option=true\n+\telse\n+\t\tmeld_has_auto_merge_option=false\n+\tfi\n+}\n\nbase-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n-- \ngitgitgadget\n"},{"id":"400781","messageId":"CANg4QoHZS0o5k_qb8BEW0yGUc8xQXSKPVA4-BHBcQkOEzO=D6Q@mail.gmail.com","threadId":"53430","inReplyTo":"pull.781.v3.git.git.1593414441313.gitgitgadget@gmail.com","subject":"Fwd: [PATCH v3] Enable auto-merge for meld to follow the vim-diff beharior","fromName":"Git Gadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-06-29T12:32:43Z","receivedAt":"2020-06-29T21:22:29Z","isPatch":true,"sender":{"key":"gitgitgadget@gmail.com","avatar":null},"body":"Re-sending, as this mail seems to have been dropped by vger.\n\n---------- Forwarded message ---------\nFrom: sunlin via GitGitGadget <gitgitgadget@gmail.com>\nDate: Mon, Jun 29, 2020 at 9:07 AM\nSubject: [PATCH v3] Enable auto-merge for meld to follow the vim-diff beharior\nTo: <git@vger.kernel.org>\nCc: sunlin <sunlin7@yahoo.com>, lin.sun <lin.sun@zoom.us>\n\n\nFrom: \"lin.sun\" <lin.sun@zoom.us>\n\nThe mergetool \"meld\" does NOT merge the no-conflict changes, while the\nmergetool \"vimdiff\" will merge the no-conflict parts and highlight the\nconflict parts.\nThis patch will make the mergetool \"meld\" similar to \"vimdiff\",\nauto-merge the no-conflict parts, highlight conflict parts.\n\nSigned-off-by: Lin Sun <lin.sun@zoom.us>\n---\n    Enable auto-merge for meld to follow the vimdiff beharior\n\n    Hi, the mergetool \"meld\" does NOT merge the no-conflict changes, while\n    the mergetool \"vimdiff\" will merge the no-conflict changes and highlight\n    the conflict parts. This patch will make the mergetool \"meld\" similar to\n    \"vimdiff\", auto-merge the no-conflict changes, highlight conflict parts.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-781%2Fsunlin7%2Fmaster-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git\npr-git-781/sunlin7/master-v3\nPull-Request: https://github.com/git/git/pull/781\n\nRange-diff vs v2:\n\n 1:  6e98a10bfa ! 1:  3b70fd0bfc Enable auto-merge for meld to follow\nthe vim-diff beharior\n     @@ Commit message\n\n       ## mergetools/meld ##\n      @@ mergetools/meld: merge_cmd () {\n     +  then\n     +          check_meld_for_output_version\n     +  fi\n     ++ if test -z \"${meld_has_auto_merge_option:+set}\"\n     ++ then\n     ++         check_meld_for_auto_merge_version\n     ++ fi\n     ++\n     ++ option_auto_merge=\n     ++ if test \"$meld_has_auto_merge_option\" = true\n     ++ then\n     ++         option_auto_merge=\"--auto-merge\"\n     ++ fi\n\n        if test \"$meld_has_output_option\" = true\n        then\n      -         \"$merge_tool_path\" --output=\"$MERGED\" \\\n     -+         \"$merge_tool_path\" --auto-merge --output=\"$MERGED\" \\\n     ++         \"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n                        \"$LOCAL\" \"$BASE\" \"$REMOTE\"\n        else\n      -         \"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n     -+         \"$merge_tool_path\" --auto-merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n     ++         \"$merge_tool_path\" $option_auto_merge \"$LOCAL\"\n\"$MERGED\" \"$REMOTE\"\n        fi\n       }\n\n     +@@ mergetools/meld: check_meld_for_output_version () {\n     +          meld_has_output_option=false\n     +  fi\n     + }\n     ++\n     ++# Check whether we should use 'meld --auto-merge ...'\n     ++check_meld_for_auto_merge_version () {\n     ++ meld_path=\"$(git config mergetool.meld.path)\"\n     ++ meld_path=\"${meld_path:-meld}\"\n     ++\n     ++ if meld_has_auto_merge_option=$(git config --bool\nmergetool.meld.hasAutoMerge)\n     ++ then\n     ++         : use configured value\n     ++ elif \"$meld_path\" --help 2>&1 |\n     ++         grep -e '--auto-merge' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n     ++ then\n     ++         : old ones mention --auto-merge and new ones just say OPTION...\n     ++         meld_has_auto_merge_option=true\n     ++ else\n     ++         meld_has_auto_merge_option=false\n     ++ fi\n     ++}\n\n\n mergetools/meld | 32 ++++++++++++++++++++++++++++++--\n 1 file changed, 30 insertions(+), 2 deletions(-)\n\ndiff --git a/mergetools/meld b/mergetools/meld\nindex 7a08470f88..91b65ff22c 100644\n--- a/mergetools/meld\n+++ b/mergetools/meld\n@@ -7,13 +7,23 @@ merge_cmd () {\n        then\n                check_meld_for_output_version\n        fi\n+       if test -z \"${meld_has_auto_merge_option:+set}\"\n+       then\n+               check_meld_for_auto_merge_version\n+       fi\n+\n+       option_auto_merge=\n+       if test \"$meld_has_auto_merge_option\" = true\n+       then\n+               option_auto_merge=\"--auto-merge\"\n+       fi\n\n        if test \"$meld_has_output_option\" = true\n        then\n-               \"$merge_tool_path\" --output=\"$MERGED\" \\\n+               \"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n                        \"$LOCAL\" \"$BASE\" \"$REMOTE\"\n        else\n-               \"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+               \"$merge_tool_path\" $option_auto_merge \"$LOCAL\"\n\"$MERGED\" \"$REMOTE\"\n        fi\n }\n\n@@ -34,3 +44,21 @@ check_meld_for_output_version () {\n                meld_has_output_option=false\n        fi\n }\n+\n+# Check whether we should use 'meld --auto-merge ...'\n+check_meld_for_auto_merge_version () {\n+       meld_path=\"$(git config mergetool.meld.path)\"\n+       meld_path=\"${meld_path:-meld}\"\n+\n+       if meld_has_auto_merge_option=$(git config --bool\nmergetool.meld.hasAutoMerge)\n+       then\n+               : use configured value\n+       elif \"$meld_path\" --help 2>&1 |\n+               grep -e '--auto-merge' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n+       then\n+               : old ones mention --auto-merge and new ones just say OPTION...\n+               meld_has_auto_merge_option=true\n+       else\n+               meld_has_auto_merge_option=false\n+       fi\n+}\n\nbase-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n--\ngitgitgadget\n"},{"id":"400785","messageId":"xmqqeepxfmdm.fsf@gitster.c.googlers.com","threadId":"53430","inReplyTo":"pull.781.v3.git.git.1593414441313.gitgitgadget@gmail.com","subject":"Re: [PATCH v3] Enable auto-merge for meld to follow the vim-diff beharior","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-06-30T00:06:13Z","receivedAt":"2020-06-30T00:06:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"sunlin via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: \"lin.sun\" <lin.sun@zoom.us>\n\nThe way this \"name <addr>\" is spelled must match the name used on\nthe Signed-off-by: line below.\n\n> The mergetool \"meld\" does NOT merge the no-conflict changes, while the\n> mergetool \"vimdiff\" will merge the no-conflict parts and highlight the\n> conflict parts.\n\nOK.\n\nHave a blank line between paragraphs here.\n\n> This patch will make the mergetool \"meld\" similar to \"vimdiff\",\n> auto-merge the no-conflict parts, highlight conflict parts.\n\nGive an order to the codebase to be like so, e.g.:\n\n    Make the mergetool used with \"meld\" backend behave similarly to\n    how \"vimdiff\" beheaves by telling it to auto-merge parts without\n    conflicts and highlight the parts with conflicts.\n\nor somethin glike that.\n\n> Signed-off-by: Lin Sun <lin.sun@zoom.us>\n> ---\n>     Enable auto-merge for meld to follow the vimdiff beharior\n>     \n>     Hi, the mergetool \"meld\" does NOT merge the no-conflict changes, while\n>     the mergetool \"vimdiff\" will merge the no-conflict changes and highlight\n>     the conflict parts. This patch will make the mergetool \"meld\" similar to\n>     \"vimdiff\", auto-merge the no-conflict changes, highlight conflict parts.\n\nThat repeats the log message and does not add much useful info.\n\n>  mergetools/meld | 32 ++++++++++++++++++++++++++++++--\n>  1 file changed, 30 insertions(+), 2 deletions(-)\n>\n> diff --git a/mergetools/meld b/mergetools/meld\n> index 7a08470f88..91b65ff22c 100644\n> --- a/mergetools/meld\n> +++ b/mergetools/meld\n> @@ -7,13 +7,23 @@ merge_cmd () {\n>  \tthen\n>  \t\tcheck_meld_for_output_version\n>  \tfi\n> +\tif test -z \"${meld_has_auto_merge_option:+set}\"\n> +\tthen\n> +\t\tcheck_meld_for_auto_merge_version\n> +\tfi\n\nThe detection part looks clumsy and inefficient.  More about it later.\n\n> +\toption_auto_merge=\n> +\tif test \"$meld_has_auto_merge_option\" = true\n> +\tthen\n> +\t\toption_auto_merge=\"--auto-merge\"\n> +\tfi\n>  \n>  \tif test \"$meld_has_output_option\" = true\n>  \tthen\n> -\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n> +\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n>  \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n>  \telse\n> -\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n> +\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n>  \tfi\n>  }\n\nThe part that chooses whether to pass --auto-merge or not and\nadjusts the command line options does look sensible.\n\nI wonder if the same \"hasAutoMerge\" option can be used by those who\ndo *not* want the new --auto-merge behaviour to opt out of this\nchange.  Is there a reason why \"meld\" offers the --auto-merge as an\noptional behaviour (which tells, at least to me, that the default\nbehaviour is not to auto-merge and makes me assume that the default\nmust be chosen by some sound reasoning, hence some users would prefer\nnot to use this new behaviour with good reasons)?\n\nI guess what I am trying to get at is, if --auto-merge is an optional\nand non-default behaviour for \"meld\" users, perhaps it is not a good\nidea to change the behaviour on them only because the version of meld\nthey run happens to support the --auto-merge as an optional behaviour.\n\nIOW, wouldn't it make more sense, and certainly make it safer\nwithout surprises to existing users, if we made the logic to\n\n    * If mergetool.meld.useAutoMerge is not set, do not pass\n      --auto-merge whether \"meld\" supports the option or not.\n\n    * If mergetool.meld.useAutoMerge is 'true', always pass it\n      without checking.\n\n    * If mergetool.meld.useAutoMerge is 'when-able' (or come up with\n      a better name if you want, perhaps 'auto'), check if \"meld\"\n      accepts \"--auto-merge\" and decide whether to pass it or not.\n\nperhaps?\n\n> +# Check whether we should use 'meld --auto-merge ...'\n> +check_meld_for_auto_merge_version () {\n> +\tmeld_path=\"$(git config mergetool.meld.path)\"\n> +\tmeld_path=\"${meld_path:-meld}\"\n> +\n> +\tif meld_has_auto_merge_option=$(git config --bool mergetool.meld.hasAutoMerge)\n> +\tthen\n> +\t\t: use configured value\n> +\telif \"$meld_path\" --help 2>&1 |\n> +\t\tgrep -e '--auto-merge' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n> +\tthen\n> +\t\t: old ones mention --auto-merge and new ones just say OPTION...\n> +\t\tmeld_has_auto_merge_option=true\n> +\telse\n> +\t\tmeld_has_auto_merge_option=false\n> +\tfi\n> +}\n\nWhen not configured, we end up running \"meld --help\" twice for two\noptions, which is not great, don't you think?  I actually think the\npart that runs \"meld --help\" and parses its output should be split\nout of the helper function \"check_meld_for_output_version\" and\ncalled \"check_meld_supported_options\" or something, so that the\nlogic to see if the --output and --auto-merge options should be\npassed can be made with at most one invocation of \"meld --help\".\nWhich may involve *NOT* having two separate helper functions\ncheck_meld_for_*_version for the tested features.\n\nOh, also, check_meld_for_*_version is nonsensical as a name for\nthese helper functions (it is not the fault of this patch---it is\nmimicking the existing practice, but that does not make the function\nname not nonsensical).  The helpers do not actually want to check a\n\"version\", they only want to see if a feature is supported.  So\nhaving \"feature\" in the name would be good, but \"version\" is not.\n\n\n\n"},{"id":"400796","messageId":"20200630074204.GA2144485@gmail.com","threadId":"53430","inReplyTo":"xmqqeepxfmdm.fsf@gitster.c.googlers.com","subject":"Re: [PATCH v3] Enable auto-merge for meld to follow the vim-diff beharior","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2020-06-30T07:42:04Z","receivedAt":"2020-06-30T07:42:09Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Mon, Jun 29, 2020 at 05:06:13PM -0700, Junio C Hamano wrote:\n> \"sunlin via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n> >  mergetools/meld | 32 ++++++++++++++++++++++++++++++--\n> >  1 file changed, 30 insertions(+), 2 deletions(-)\n> >\n> > diff --git a/mergetools/meld b/mergetools/meld\n> > index 7a08470f88..91b65ff22c 100644\n> > --- a/mergetools/meld\n> > +++ b/mergetools/meld\n> > @@ -7,13 +7,23 @@ merge_cmd () {\n> >  \tthen\n> >  \t\tcheck_meld_for_output_version\n> >  \tfi\n> > +\tif test -z \"${meld_has_auto_merge_option:+set}\"\n> > +\tthen\n> > +\t\tcheck_meld_for_auto_merge_version\n> > +\tfi\n> \n> The detection part looks clumsy and inefficient.  More about it later.\n\n\nSorry for not noticing your reply here earlier.  I agree with everything\nyou wrote here, and rescind my earlier sign-off.  Combining as you\nsuggested below is best IMO as well.\n\n> \n> > +\toption_auto_merge=\n> > +\tif test \"$meld_has_auto_merge_option\" = true\n> > +\tthen\n> > +\t\toption_auto_merge=\"--auto-merge\"\n> > +\tfi\n> >  \n> >  \tif test \"$meld_has_output_option\" = true\n> >  \tthen\n> > -\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n> > +\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n> >  \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n> >  \telse\n> > -\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n> > +\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n> >  \tfi\n> >  }\n> \n> The part that chooses whether to pass --auto-merge or not and\n> adjusts the command line options does look sensible.\n> \n> I wonder if the same \"hasAutoMerge\" option can be used by those who\n> do *not* want the new --auto-merge behaviour to opt out of this\n> change.  Is there a reason why \"meld\" offers the --auto-merge as an\n> optional behaviour (which tells, at least to me, that the default\n> behaviour is not to auto-merge and makes me assume that the default\n> must be chosen by some sound reasoning, hence some users would prefer\n> not to use this new behaviour with good reasons)?\n> \n> I guess what I am trying to get at is, if --auto-merge is an optional\n> and non-default behaviour for \"meld\" users, perhaps it is not a good\n> idea to change the behaviour on them only because the version of meld\n> they run happens to support the --auto-merge as an optional behaviour.\n> \n> IOW, wouldn't it make more sense, and certainly make it safer\n> without surprises to existing users, if we made the logic to\n> \n>     * If mergetool.meld.useAutoMerge is not set, do not pass\n>       --auto-merge whether \"meld\" supports the option or not.\n> \n>     * If mergetool.meld.useAutoMerge is 'true', always pass it\n>       without checking.\n> \n>     * If mergetool.meld.useAutoMerge is 'when-able' (or come up with\n>       a better name if you want, perhaps 'auto'), check if \"meld\"\n>       accepts \"--auto-merge\" and decide whether to pass it or not.\n> \n> perhaps?\n\n\nI like the idea of having it be auto/true/false, and perhaps \"auto\"\nwould be a sensible default if more users benefit from it than not.\n\nSunlin, do you have an opinion on what the default should be?\n\n\n\n> > +# Check whether we should use 'meld --auto-merge ...'\n> > +check_meld_for_auto_merge_version () {\n> > +\tmeld_path=\"$(git config mergetool.meld.path)\"\n\nSmall sug -- this command substitution doesn't need the enclosing\nquotes.\n\n\tmeld_path=$(git config mergetool.meld.path || echo meld)\n\nshould be sufficient.  Are we okay with `|| echo meld`?\nIf so, it would let us drop this line below.\n\n> > +\tmeld_path=\"${meld_path:-meld}\"\n\n\n> > +\n> > +\tif meld_has_auto_merge_option=$(git config --bool mergetool.meld.hasAutoMerge)\n> > +\tthen\n> > +\t\t: use configured value\n> > +\telif \"$meld_path\" --help 2>&1 |\n> > +\t\tgrep -e '--auto-merge' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n> > +\tthen\n> > +\t\t: old ones mention --auto-merge and new ones just say OPTION...\n> > +\t\tmeld_has_auto_merge_option=true\n> > +\telse\n> > +\t\tmeld_has_auto_merge_option=false\n> > +\tfi\n> > +}\n> \n> When not configured, we end up running \"meld --help\" twice for two\n> options, which is not great, don't you think?  I actually think the\n> part that runs \"meld --help\" and parses its output should be split\n> out of the helper function \"check_meld_for_output_version\" and\n> called \"check_meld_supported_options\" or something, so that the\n> logic to see if the --output and --auto-merge options should be\n> passed can be made with at most one invocation of \"meld --help\".\n> Which may involve *NOT* having two separate helper functions\n> check_meld_for_*_version for the tested features.\n\n\nI'm 100% on board with this suggestion.\n\n> \n> Oh, also, check_meld_for_*_version is nonsensical as a name for\n> these helper functions (it is not the fault of this patch---it is\n> mimicking the existing practice, but that does not make the function\n> name not nonsensical).  The helpers do not actually want to check a\n> \"version\", they only want to see if a feature is supported.  So\n> having \"feature\" in the name would be good, but \"version\" is not.\n\n\nDitto.\n-- \nDavid\n"},{"id":"400800","messageId":"f61a01d64ed1$1e36af40$5aa40dc0$@zoom.us","threadId":"53430","inReplyTo":"20200630074204.GA2144485@gmail.com","subject":"RE: [PATCH v3] Enable auto-merge for meld to follow the vim-diff beharior","fromName":"","fromEmail":"lin.sun@zoom.us","sentAt":"2020-06-30T11:25:07Z","receivedAt":"2020-06-30T11:25:16Z","isPatch":true,"sender":{"key":"lin.sun@zoom.us","avatar":null},"body":"Hi David, Junio,\n\nAppreciate for your comments, I rewrite the \"mergetool/meld\" to follow your comments and suggestions.\nIt will respect the git config first, then detect the options if no configuration for them, and also reduce the subprocess calling.\nBoth the modified-file and patch-file are appended.\nPlease review again. Thanks\n\nRegards\nLin Sun\n\n\nFrom 93ae3ec011e7b55cc9971f91345cb4aab5189cb4 Mon Sep 17 00:00:00 2001\nFrom: \"lin.sun\" <lin.sun@zoom.us>\nDate: Thu, 7 May 2020 07:31:14 +0800\nSubject: [PATCH] Enable auto-merge for meld to follow the vim-diff beharior\n\nMake the mergetool used with \"meld\" backend behave similarly to\nhow \"vimdiff\" beheaves by telling it to auto-merge parts without\nconflicts and highlight the parts with conflicts.\n\nSigned-off-by: lin.sun <lin.sun@zoom.us>\n---\n mergetools/meld | 73 ++++++++++++++++++++++++++++++++++++++++++++-------------\n 1 file changed, 57 insertions(+), 16 deletions(-)\n\ndiff --git a/mergetools/meld b/mergetools/meld\nindex 7a08470..1b92771 100644\n--- a/mergetools/meld\n+++ b/mergetools/meld\n@@ -3,34 +3,75 @@ diff_cmd () {\n }\n \n merge_cmd () {\n-\tif test -z \"${meld_has_output_option:+set}\"\n+\tcheck_meld_for_features\n+\n+\toption_auto_merge=\n+\tif test \"$meld_has_auto_merge_option\" = true\n \tthen\n-\t\tcheck_meld_for_output_version\n+\t\toption_auto_merge=\"--auto-merge\"\n \tfi\n \n \tif test \"$meld_has_output_option\" = true\n \tthen\n-\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n+\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \telse\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \tfi\n }\n \n-# Check whether we should use 'meld --output <file>'\n-check_meld_for_output_version () {\n-\tmeld_path=\"$(git config mergetool.meld.path)\"\n-\tmeld_path=\"${meld_path:-meld}\"\n+# Get meld help message\n+get_meld_help_msg () {\n+\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n+  $meld_path --help 2>&1\n+}\n \n-\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+# Check the features and set flags\n+check_meld_for_features () {\n+\t# Check whether we should use 'meld --output <file>'\n+\tif test -z \"${meld_has_output_option:+set}\"\n \tthen\n-\t\t: use configured value\n-\telif \"$meld_path\" --help 2>&1 |\n-\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n+\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+\t\tif test \"$meld_has_output_option\" = true -o \\\n+\t\t\t\t\t\t\"$meld_has_output_option\" = false\n+\t\tthen\n+\t\t\t: use configured value\n+\t\telse\t\t\t\t\t\t\t\t\t\t\t\t# treat meld_has_output_option as \"auto\"\n+\t\t\tif test -z \"$meld_help_msg\"\n+\t\t\tthen\n+\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n+\t\t\tfi\n+\n+\t\t\tif echo \"$meld_help_msg\" |\n+\t\t\t\t\t\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n+\t\t\tthen\n+\t\t\t\t: old ones mention --output and new ones just say OPTION...\n+\t\t\t\tmeld_has_output_option=true\n+\t\t\telse\n+\t\t\t\tmeld_has_output_option=false\n+\t\t\tfi\n+\t\tfi\n+\tfi\n+\t# Check whether we should use 'meld --auto-merge ...'\n+\tif test -z \"${meld_has_auto_merge_option:+set}\"\n \tthen\n-\t\t: old ones mention --output and new ones just say OPTION...\n-\t\tmeld_has_output_option=true\n-\telse\n-\t\tmeld_has_output_option=false\n+\t\tmeld_has_auto_merge_option=$(git config --bool mergetool.meld.hasAutoMerge)\n+\t\tif test \"$meld_has_auto_merge_option\" = true -o \\\n+\t\t\t\t\t\t\"$meld_has_auto_merge_option\" = false\n+\t\tthen\n+\t\t\t: use configured value\n+\t\telse\t\t\t\t\t\t\t\t\t\t\t\t# treat meld_has_auto_merge_option as \"auto\"\n+\t\t\tif test -z \"$meld_help_msg\"\n+\t\t\tthen\n+\t\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n+\t\t\tfi\n+\n+\t\t\tif echo \"$meld_help_msg\" | grep -e '--auto-merge' >/dev/null\n+\t\t\tthen\n+\t\t\t\t\tmeld_has_auto_merge_option=true\n+\t\t\telse\n+\t\t\t\tmeld_has_auto_merge_option=false\n+\t\t\tfi\n+\t\tfi\n \tfi\n }\n-- \n2.2.0\n\n"},{"id":"400801","messageId":"pull.781.v4.git.git.1593516397380.gitgitgadget@gmail.com","threadId":"53430","inReplyTo":"pull.781.v3.git.git.1593414441313.gitgitgadget@gmail.com","subject":"[PATCH v4] Enable auto-merge for meld to follow the vim-diff beharior","fromName":"sunlin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-06-30T11:26:37Z","receivedAt":"2020-06-30T11:26:42Z","isPatch":true,"sender":{"key":"name:sunlin","avatar":null},"body":"From: \"lin.sun\" <lin.sun@zoom.us>\n\nMake the mergetool used with \"meld\" backend behave similarly to\nhow \"vimdiff\" beheaves by telling it to auto-merge parts without\nconflicts and highlight the parts with conflicts.\n\nSigned-off-by: lin.sun <lin.sun@zoom.us>\n---\n    Enable auto-merge for meld to follow the vimdiff beharior\n    \n    Hi, the mergetool \"meld\" does NOT merge the no-conflict changes, while\n    the mergetool \"vimdiff\" will merge the no-conflict changes and highlight\n    the conflict parts. This patch will make the mergetool \"meld\" similar to\n    \"vimdiff\", auto-merge the no-conflict changes, highlight conflict parts.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-781%2Fsunlin7%2Fmaster-v4\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-781/sunlin7/master-v4\nPull-Request: https://github.com/git/git/pull/781\n\nRange-diff vs v3:\n\n 1:  3b70fd0bfc ! 1:  93ae3ec011 Enable auto-merge for meld to follow the vim-diff beharior\n     @@ Metadata\n       ## Commit message ##\n          Enable auto-merge for meld to follow the vim-diff beharior\n      \n     -    The mergetool \"meld\" does NOT merge the no-conflict changes, while the\n     -    mergetool \"vimdiff\" will merge the no-conflict parts and highlight the\n     -    conflict parts.\n     -    This patch will make the mergetool \"meld\" similar to \"vimdiff\",\n     -    auto-merge the no-conflict parts, highlight conflict parts.\n     +    Make the mergetool used with \"meld\" backend behave similarly to\n     +    how \"vimdiff\" beheaves by telling it to auto-merge parts without\n     +    conflicts and highlight the parts with conflicts.\n      \n     -    Signed-off-by: Lin Sun <lin.sun@zoom.us>\n     +    Signed-off-by: lin.sun <lin.sun@zoom.us>\n      \n       ## mergetools/meld ##\n     -@@ mergetools/meld: merge_cmd () {\n     - \tthen\n     - \t\tcheck_meld_for_output_version\n     - \tfi\n     -+\tif test -z \"${meld_has_auto_merge_option:+set}\"\n     -+\tthen\n     -+\t\tcheck_meld_for_auto_merge_version\n     -+\tfi\n     +@@ mergetools/meld: diff_cmd () {\n     + }\n     + \n     + merge_cmd () {\n     +-\tif test -z \"${meld_has_output_option:+set}\"\n     ++\tcheck_meld_for_features\n      +\n      +\toption_auto_merge=\n      +\tif test \"$meld_has_auto_merge_option\" = true\n     -+\tthen\n     + \tthen\n     +-\t\tcheck_meld_for_output_version\n      +\t\toption_auto_merge=\"--auto-merge\"\n     -+\tfi\n     + \tfi\n       \n       \tif test \"$meld_has_output_option\" = true\n       \tthen\n     @@ mergetools/meld: merge_cmd () {\n       \tfi\n       }\n       \n     -@@ mergetools/meld: check_meld_for_output_version () {\n     - \t\tmeld_has_output_option=false\n     - \tfi\n     - }\n     -+\n     -+# Check whether we should use 'meld --auto-merge ...'\n     -+check_meld_for_auto_merge_version () {\n     -+\tmeld_path=\"$(git config mergetool.meld.path)\"\n     -+\tmeld_path=\"${meld_path:-meld}\"\n     +-# Check whether we should use 'meld --output <file>'\n     +-check_meld_for_output_version () {\n     +-\tmeld_path=\"$(git config mergetool.meld.path)\"\n     +-\tmeld_path=\"${meld_path:-meld}\"\n     ++# Get meld help message\n     ++get_meld_help_msg () {\n     ++\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n     ++  $meld_path --help 2>&1\n     ++}\n     + \n     +-\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n     ++# Check the features and set flags\n     ++check_meld_for_features () {\n     ++\t# Check whether we should use 'meld --output <file>'\n     ++\tif test -z \"${meld_has_output_option:+set}\"\n     + \tthen\n     +-\t\t: use configured value\n     +-\telif \"$meld_path\" --help 2>&1 |\n     +-\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n     ++\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n     ++\t\tif test \"$meld_has_output_option\" = true -o \\\n     ++\t\t\t\t\t\t\"$meld_has_output_option\" = false\n     ++\t\tthen\n     ++\t\t\t: use configured value\n     ++\t\telse\t\t\t\t\t\t\t\t\t\t\t\t# treat meld_has_output_option as \"auto\"\n     ++\t\t\tif test -z \"$meld_help_msg\"\n     ++\t\t\tthen\n     ++\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n     ++\t\t\tfi\n      +\n     -+\tif meld_has_auto_merge_option=$(git config --bool mergetool.meld.hasAutoMerge)\n     -+\tthen\n     -+\t\t: use configured value\n     -+\telif \"$meld_path\" --help 2>&1 |\n     -+\t\tgrep -e '--auto-merge' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n     -+\tthen\n     -+\t\t: old ones mention --auto-merge and new ones just say OPTION...\n     -+\t\tmeld_has_auto_merge_option=true\n     -+\telse\n     -+\t\tmeld_has_auto_merge_option=false\n     ++\t\t\tif echo \"$meld_help_msg\" |\n     ++\t\t\t\t\t\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n     ++\t\t\tthen\n     ++\t\t\t\t: old ones mention --output and new ones just say OPTION...\n     ++\t\t\t\tmeld_has_output_option=true\n     ++\t\t\telse\n     ++\t\t\t\tmeld_has_output_option=false\n     ++\t\t\tfi\n     ++\t\tfi\n      +\tfi\n     -+}\n     ++\t# Check whether we should use 'meld --auto-merge ...'\n     ++\tif test -z \"${meld_has_auto_merge_option:+set}\"\n     + \tthen\n     +-\t\t: old ones mention --output and new ones just say OPTION...\n     +-\t\tmeld_has_output_option=true\n     +-\telse\n     +-\t\tmeld_has_output_option=false\n     ++\t\tmeld_has_auto_merge_option=$(git config --bool mergetool.meld.hasAutoMerge)\n     ++\t\tif test \"$meld_has_auto_merge_option\" = true -o \\\n     ++\t\t\t\t\t\t\"$meld_has_auto_merge_option\" = false\n     ++\t\tthen\n     ++\t\t\t: use configured value\n     ++\t\telse\t\t\t\t\t\t\t\t\t\t\t\t# treat meld_has_auto_merge_option as \"auto\"\n     ++\t\t\tif test -z \"$meld_help_msg\"\n     ++\t\t\tthen\n     ++\t\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n     ++\t\t\tfi\n     ++\n     ++\t\t\tif echo \"$meld_help_msg\" | grep -e '--auto-merge' >/dev/null\n     ++\t\t\tthen\n     ++\t\t\t\t\tmeld_has_auto_merge_option=true\n     ++\t\t\telse\n     ++\t\t\t\tmeld_has_auto_merge_option=false\n     ++\t\t\tfi\n     ++\t\tfi\n     + \tfi\n     + }\n\n\n mergetools/meld | 73 ++++++++++++++++++++++++++++++++++++++-----------\n 1 file changed, 57 insertions(+), 16 deletions(-)\n\ndiff --git a/mergetools/meld b/mergetools/meld\nindex 7a08470f88..1b92771228 100644\n--- a/mergetools/meld\n+++ b/mergetools/meld\n@@ -3,34 +3,75 @@ diff_cmd () {\n }\n \n merge_cmd () {\n-\tif test -z \"${meld_has_output_option:+set}\"\n+\tcheck_meld_for_features\n+\n+\toption_auto_merge=\n+\tif test \"$meld_has_auto_merge_option\" = true\n \tthen\n-\t\tcheck_meld_for_output_version\n+\t\toption_auto_merge=\"--auto-merge\"\n \tfi\n \n \tif test \"$meld_has_output_option\" = true\n \tthen\n-\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n+\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \telse\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \tfi\n }\n \n-# Check whether we should use 'meld --output <file>'\n-check_meld_for_output_version () {\n-\tmeld_path=\"$(git config mergetool.meld.path)\"\n-\tmeld_path=\"${meld_path:-meld}\"\n+# Get meld help message\n+get_meld_help_msg () {\n+\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n+  $meld_path --help 2>&1\n+}\n \n-\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+# Check the features and set flags\n+check_meld_for_features () {\n+\t# Check whether we should use 'meld --output <file>'\n+\tif test -z \"${meld_has_output_option:+set}\"\n \tthen\n-\t\t: use configured value\n-\telif \"$meld_path\" --help 2>&1 |\n-\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n+\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+\t\tif test \"$meld_has_output_option\" = true -o \\\n+\t\t\t\t\t\t\"$meld_has_output_option\" = false\n+\t\tthen\n+\t\t\t: use configured value\n+\t\telse\t\t\t\t\t\t\t\t\t\t\t\t# treat meld_has_output_option as \"auto\"\n+\t\t\tif test -z \"$meld_help_msg\"\n+\t\t\tthen\n+\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n+\t\t\tfi\n+\n+\t\t\tif echo \"$meld_help_msg\" |\n+\t\t\t\t\t\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n+\t\t\tthen\n+\t\t\t\t: old ones mention --output and new ones just say OPTION...\n+\t\t\t\tmeld_has_output_option=true\n+\t\t\telse\n+\t\t\t\tmeld_has_output_option=false\n+\t\t\tfi\n+\t\tfi\n+\tfi\n+\t# Check whether we should use 'meld --auto-merge ...'\n+\tif test -z \"${meld_has_auto_merge_option:+set}\"\n \tthen\n-\t\t: old ones mention --output and new ones just say OPTION...\n-\t\tmeld_has_output_option=true\n-\telse\n-\t\tmeld_has_output_option=false\n+\t\tmeld_has_auto_merge_option=$(git config --bool mergetool.meld.hasAutoMerge)\n+\t\tif test \"$meld_has_auto_merge_option\" = true -o \\\n+\t\t\t\t\t\t\"$meld_has_auto_merge_option\" = false\n+\t\tthen\n+\t\t\t: use configured value\n+\t\telse\t\t\t\t\t\t\t\t\t\t\t\t# treat meld_has_auto_merge_option as \"auto\"\n+\t\t\tif test -z \"$meld_help_msg\"\n+\t\t\tthen\n+\t\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n+\t\t\tfi\n+\n+\t\t\tif echo \"$meld_help_msg\" | grep -e '--auto-merge' >/dev/null\n+\t\t\tthen\n+\t\t\t\t\tmeld_has_auto_merge_option=true\n+\t\t\telse\n+\t\t\t\tmeld_has_auto_merge_option=false\n+\t\t\tfi\n+\t\tfi\n \tfi\n }\n\nbase-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n-- \ngitgitgadget\n"},{"id":"400802","messageId":"f78601d64ed2$e5c54de0$b14fe9a0$@zoom.us","threadId":"53430","inReplyTo":"20200630074204.GA2144485@gmail.com","subject":"[PATCH v3] Enable auto-merge for meld to follow the vim-diff beharior","fromName":"","fromEmail":"lin.sun@zoom.us","sentAt":"2020-06-30T11:37:51Z","receivedAt":"2020-06-30T11:38:00Z","isPatch":true,"sender":{"key":"lin.sun@zoom.us","avatar":null},"body":"The last change also available in https://github.com/git/git/pull/781/files.\n\n"},{"id":"400832","messageId":"xmqq1rlwft6q.fsf@gitster.c.googlers.com","threadId":"53430","inReplyTo":"20200630074204.GA2144485@gmail.com","subject":"Re: [PATCH v3] Enable auto-merge for meld to follow the vim-diff beharior","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-06-30T15:51:25Z","receivedAt":"2020-06-30T15:51:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Aguilar <davvid@gmail.com> writes:\n\n> On Mon, Jun 29, 2020 at 05:06:13PM -0700, Junio C Hamano wrote:\n> ...\n>> I guess what I am trying to get at is, if --auto-merge is an optional\n>> and non-default behaviour for \"meld\" users, perhaps it is not a good\n>> idea to change the behaviour on them only because the version of meld\n>> they run happens to support the --auto-merge as an optional behaviour.\n>> \n>> IOW, wouldn't it make more sense, and certainly make it safer\n>> without surprises to existing users, if we made the logic to\n>> \n>>     * If mergetool.meld.useAutoMerge is not set, do not pass\n>>       --auto-merge whether \"meld\" supports the option or not.\n>> \n>>     * If mergetool.meld.useAutoMerge is 'true', always pass it\n>>       without checking.\n>> \n>>     * If mergetool.meld.useAutoMerge is 'when-able' (or come up with\n>>       a better name if you want, perhaps 'auto'), check if \"meld\"\n>>       accepts \"--auto-merge\" and decide whether to pass it or not.\n>> \n>> perhaps?\n>\n> I like the idea of having it be auto/true/false, and perhaps \"auto\"\n> would be a sensible default if more users benefit from it than not.\n\nThe principle I've stuck to running this project for the past years\nis to avoid hurting 1 user more than trying to please 10 others.  As\nI do not use meld regularly myself, I do not know if there are use\ncases that are helped by the fact that \"--auto-merge\" is not the\ndefault behaviour among \"meld\" users (not limited to \"users of\nmergetool with meld backend\").  And if there are, suddenly changing\nthe behaviour to those who have happily been using mergetool with\nmeld backend that does not \"--auto-merge\" can be disservice to our\nusers.  Until I hear something along the lines of \"Even though meld\nrequires --auto-merge from users merely due to historical reasons,\nthese days everybody hates the fact that it is not the default\", I'd\nrecommend against making 'auto' the default on our side, just to be\nsafe, even if our intuition is that majority of users may want the\n\"--auto-merge\" behaviour.\n\nBut I am not a user of mergetool with meld backend, so...\n\nThanks.\n"},{"id":"400835","messageId":"20200630162333.GA15821@danh.dev","threadId":"53430","inReplyTo":"pull.781.v4.git.git.1593516397380.gitgitgadget@gmail.com","subject":"Re: [PATCH v4] Enable auto-merge for meld to follow the vim-diff beharior","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-06-30T16:23:33Z","receivedAt":"2020-06-30T16:23:41Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-06-30 11:26:37+0000, sunlin via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> From: \"lin.sun\" <lin.sun@zoom.us>\n\nThis part needs to be fixed, aka, use your real name here :).\n\n> \n> Make the mergetool used with \"meld\" backend behave similarly to\n> how \"vimdiff\" beheaves by telling it to auto-merge parts without\n> conflicts and highlight the parts with conflicts.\n> \n> Signed-off-by: lin.sun <lin.sun@zoom.us>\n> ---\n>     Enable auto-merge for meld to follow the vimdiff beharior\n>     \n>     Hi, the mergetool \"meld\" does NOT merge the no-conflict changes, while\n>     the mergetool \"vimdiff\" will merge the no-conflict changes and highlight\n>     the conflict parts. This patch will make the mergetool \"meld\" similar to\n>     \"vimdiff\", auto-merge the no-conflict changes, highlight conflict parts.\n> \n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-781%2Fsunlin7%2Fmaster-v4\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-781/sunlin7/master-v4\n> Pull-Request: https://github.com/git/git/pull/781\n> \n> Range-diff vs v3:\n> \n>  1:  3b70fd0bfc ! 1:  93ae3ec011 Enable auto-merge for meld to follow the vim-diff beharior\n>      @@ Metadata\n>        ## Commit message ##\n>           Enable auto-merge for meld to follow the vim-diff beharior\n>       \n>      -    The mergetool \"meld\" does NOT merge the no-conflict changes, while the\n>      -    mergetool \"vimdiff\" will merge the no-conflict parts and highlight the\n>      -    conflict parts.\n>      -    This patch will make the mergetool \"meld\" similar to \"vimdiff\",\n>      -    auto-merge the no-conflict parts, highlight conflict parts.\n>      +    Make the mergetool used with \"meld\" backend behave similarly to\n>      +    how \"vimdiff\" beheaves by telling it to auto-merge parts without\n>      +    conflicts and highlight the parts with conflicts.\n>       \n>      -    Signed-off-by: Lin Sun <lin.sun@zoom.us>\n>      +    Signed-off-by: lin.sun <lin.sun@zoom.us>\n>       \n>        ## mergetools/meld ##\n>      -@@ mergetools/meld: merge_cmd () {\n>      - \tthen\n>      - \t\tcheck_meld_for_output_version\n>      - \tfi\n>      -+\tif test -z \"${meld_has_auto_merge_option:+set}\"\n>      -+\tthen\n>      -+\t\tcheck_meld_for_auto_merge_version\n>      -+\tfi\n>      +@@ mergetools/meld: diff_cmd () {\n>      + }\n>      + \n>      + merge_cmd () {\n>      +-\tif test -z \"${meld_has_output_option:+set}\"\n>      ++\tcheck_meld_for_features\n>       +\n>       +\toption_auto_merge=\n>       +\tif test \"$meld_has_auto_merge_option\" = true\n>      -+\tthen\n>      + \tthen\n>      +-\t\tcheck_meld_for_output_version\n>       +\t\toption_auto_merge=\"--auto-merge\"\n>      -+\tfi\n>      + \tfi\n>        \n>        \tif test \"$meld_has_output_option\" = true\n>        \tthen\n>      @@ mergetools/meld: merge_cmd () {\n>        \tfi\n>        }\n>        \n>      -@@ mergetools/meld: check_meld_for_output_version () {\n>      - \t\tmeld_has_output_option=false\n>      - \tfi\n>      - }\n>      -+\n>      -+# Check whether we should use 'meld --auto-merge ...'\n>      -+check_meld_for_auto_merge_version () {\n>      -+\tmeld_path=\"$(git config mergetool.meld.path)\"\n>      -+\tmeld_path=\"${meld_path:-meld}\"\n>      +-# Check whether we should use 'meld --output <file>'\n>      +-check_meld_for_output_version () {\n>      +-\tmeld_path=\"$(git config mergetool.meld.path)\"\n>      +-\tmeld_path=\"${meld_path:-meld}\"\n>      ++# Get meld help message\n>      ++get_meld_help_msg () {\n>      ++\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n>      ++  $meld_path --help 2>&1\n>      ++}\n>      + \n>      +-\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n>      ++# Check the features and set flags\n>      ++check_meld_for_features () {\n>      ++\t# Check whether we should use 'meld --output <file>'\n>      ++\tif test -z \"${meld_has_output_option:+set}\"\n>      + \tthen\n>      +-\t\t: use configured value\n>      +-\telif \"$meld_path\" --help 2>&1 |\n>      +-\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n>      ++\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n>      ++\t\tif test \"$meld_has_output_option\" = true -o \\\n>      ++\t\t\t\t\t\t\"$meld_has_output_option\" = false\n>      ++\t\tthen\n>      ++\t\t\t: use configured value\n>      ++\t\telse\t\t\t\t\t\t\t\t\t\t\t\t# treat meld_has_output_option as \"auto\"\n>      ++\t\t\tif test -z \"$meld_help_msg\"\n>      ++\t\t\tthen\n>      ++\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n>      ++\t\t\tfi\n>       +\n>      -+\tif meld_has_auto_merge_option=$(git config --bool mergetool.meld.hasAutoMerge)\n>      -+\tthen\n>      -+\t\t: use configured value\n>      -+\telif \"$meld_path\" --help 2>&1 |\n>      -+\t\tgrep -e '--auto-merge' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n>      -+\tthen\n>      -+\t\t: old ones mention --auto-merge and new ones just say OPTION...\n>      -+\t\tmeld_has_auto_merge_option=true\n>      -+\telse\n>      -+\t\tmeld_has_auto_merge_option=false\n>      ++\t\t\tif echo \"$meld_help_msg\" |\n>      ++\t\t\t\t\t\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n>      ++\t\t\tthen\n>      ++\t\t\t\t: old ones mention --output and new ones just say OPTION...\n>      ++\t\t\t\tmeld_has_output_option=true\n>      ++\t\t\telse\n>      ++\t\t\t\tmeld_has_output_option=false\n>      ++\t\t\tfi\n>      ++\t\tfi\n>       +\tfi\n>      -+}\n>      ++\t# Check whether we should use 'meld --auto-merge ...'\n>      ++\tif test -z \"${meld_has_auto_merge_option:+set}\"\n>      + \tthen\n>      +-\t\t: old ones mention --output and new ones just say OPTION...\n>      +-\t\tmeld_has_output_option=true\n>      +-\telse\n>      +-\t\tmeld_has_output_option=false\n>      ++\t\tmeld_has_auto_merge_option=$(git config --bool mergetool.meld.hasAutoMerge)\n>      ++\t\tif test \"$meld_has_auto_merge_option\" = true -o \\\n>      ++\t\t\t\t\t\t\"$meld_has_auto_merge_option\" = false\n>      ++\t\tthen\n>      ++\t\t\t: use configured value\n>      ++\t\telse\t\t\t\t\t\t\t\t\t\t\t\t# treat meld_has_auto_merge_option as \"auto\"\n>      ++\t\t\tif test -z \"$meld_help_msg\"\n>      ++\t\t\tthen\n>      ++\t\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n>      ++\t\t\tfi\n>      ++\n>      ++\t\t\tif echo \"$meld_help_msg\" | grep -e '--auto-merge' >/dev/null\n>      ++\t\t\tthen\n>      ++\t\t\t\t\tmeld_has_auto_merge_option=true\n>      ++\t\t\telse\n>      ++\t\t\t\tmeld_has_auto_merge_option=false\n>      ++\t\t\tfi\n>      ++\t\tfi\n>      + \tfi\n>      + }\n> \n> \n>  mergetools/meld | 73 ++++++++++++++++++++++++++++++++++++++-----------\n>  1 file changed, 57 insertions(+), 16 deletions(-)\n> \n> diff --git a/mergetools/meld b/mergetools/meld\n> index 7a08470f88..1b92771228 100644\n> --- a/mergetools/meld\n> +++ b/mergetools/meld\n> @@ -3,34 +3,75 @@ diff_cmd () {\n>  }\n>  \n>  merge_cmd () {\n> -\tif test -z \"${meld_has_output_option:+set}\"\n> +\tcheck_meld_for_features\n> +\n> +\toption_auto_merge=\n> +\tif test \"$meld_has_auto_merge_option\" = true\n\nWe probably want \"meld_want_auto_merge\"?\nSomeone may use meld that has --auto-merge but don't want to use it.\n\n>  \tthen\n> -\t\tcheck_meld_for_output_version\n> +\t\toption_auto_merge=\"--auto-merge\"\n>  \tfi\n>  \n>  \tif test \"$meld_has_output_option\" = true\n>  \tthen\n> -\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n> +\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n>  \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n>  \telse\n> -\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n> +\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n>  \tfi\n>  }\n>  \n> -# Check whether we should use 'meld --output <file>'\n> -check_meld_for_output_version () {\n> -\tmeld_path=\"$(git config mergetool.meld.path)\"\n> -\tmeld_path=\"${meld_path:-meld}\"\n> +# Get meld help message\n> +get_meld_help_msg () {\n> +\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n> +  $meld_path --help 2>&1\n\nWe always use TAB for indentation.\n\n> +}\n>  \n> -\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n> +# Check the features and set flags\n> +check_meld_for_features () {\n> +\t# Check whether we should use 'meld --output <file>'\n> +\tif test -z \"${meld_has_output_option:+set}\"\n>  \tthen\n> -\t\t: use configured value\n> -\telif \"$meld_path\" --help 2>&1 |\n> -\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n> +\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n> +\t\tif test \"$meld_has_output_option\" = true -o \\\n> +\t\t\t\t\t\t\"$meld_has_output_option\" = false\n> +\t\tthen\n> +\t\t\t: use configured value\n> +\t\telse\t\t\t\t\t\t\t\t\t\t\t\t# treat meld_has_output_option as \"auto\"\n\nPlease don't put your comment like this,\nit's too far away from code,\nreader may miss that.\n\n> +\t\t\tif test -z \"$meld_help_msg\"\n> +\t\t\tthen\n> +\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n> +\t\t\tfi\n> +\n> +\t\t\tif echo \"$meld_help_msg\" |\n> +\t\t\t\t\t\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n\nI probably write like this to save a pipe, a fork and an exec:\n\n\tcase \"$meld_help_msg\" in\n\t*\"[OPTION\"???\"]\"*)\n\t\tmeld_has_output_option=true ;;\n\t*)\n\t\tmeld_has_output_option=false ;;\n\tesac\n\nIf you don't like the case ... esac,\nI prefer \"grep -q\" in this case,\nI didn't check how much portable it's.\nDon't forget to hide the error with 2>/dev/null (or in you case 2>&1)\n\n> +\t\t\tthen\n> +\t\t\t\t: old ones mention --output and new ones just say OPTION...\n> +\t\t\t\tmeld_has_output_option=true\n> +\t\t\telse\n> +\t\t\t\tmeld_has_output_option=false\n> +\t\t\tfi\n> +\t\tfi\n> +\tfi\n> +\t# Check whether we should use 'meld --auto-merge ...'\n> +\tif test -z \"${meld_has_auto_merge_option:+set}\"\n>  \tthen\n> -\t\t: old ones mention --output and new ones just say OPTION...\n> -\t\tmeld_has_output_option=true\n\nI think something was forgotten here?\n\n> -\telse\n> -\t\tmeld_has_output_option=false\n> +\t\tmeld_has_auto_merge_option=$(git config --bool mergetool.meld.hasAutoMerge)\n> +\t\tif test \"$meld_has_auto_merge_option\" = true -o \\\n> +\t\t\t\t\t\t\"$meld_has_auto_merge_option\" = false\n> +\t\tthen\n> +\t\t\t: use configured value\n> +\t\telse\t\t\t\t\t\t\t\t\t\t\t\t# treat meld_has_auto_merge_option as \"auto\"\n> +\t\t\tif test -z \"$meld_help_msg\"\n> +\t\t\tthen\n> +\t\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n> +\t\t\tfi\n> +\n> +\t\t\tif echo \"$meld_help_msg\" | grep -e '--auto-merge' >/dev/null\n\nAnd I'll use the same \"case ... esac\" above for this one :)\n\n> +\t\t\tthen\n> +\t\t\t\t\tmeld_has_auto_merge_option=true\n> +\t\t\telse\n> +\t\t\t\tmeld_has_auto_merge_option=false\n> +\t\t\tfi\n> +\t\tfi\n>  \tfi\n>  }\n> \n> base-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n> -- \n> gitgitgadget\n\n-- \nDanh\n"},{"id":"400859","messageId":"20200630230145.GB15821@danh.dev","threadId":"53430","inReplyTo":"20200630162333.GA15821@danh.dev","subject":"Re: [PATCH v4] Enable auto-merge for meld to follow the vim-diff beharior","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-06-30T23:01:45Z","receivedAt":"2020-06-30T23:01:51Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-06-30 23:23:33+0700, Đoàn Trần Công Danh <congdanhqx@gmail.com> wrote:\n> > +\t\t\tthen\n> > +\t\t\t\t: old ones mention --output and new ones just say OPTION...\n> > +\t\t\t\tmeld_has_output_option=true\n> > +\t\t\telse\n> > +\t\t\t\tmeld_has_output_option=false\n> > +\t\t\tfi\n> > +\t\tfi\n> > +\tfi\n> > +\t# Check whether we should use 'meld --auto-merge ...'\n> > +\tif test -z \"${meld_has_auto_merge_option:+set}\"\n> >  \tthen\n> > -\t\t: old ones mention --output and new ones just say OPTION...\n> > -\t\tmeld_has_output_option=true\n> \n> I think something was forgotten here?\n\nPlease read this line as:\nIs this a copy-paste and forget to edit-afterward.\nSomehow that line was lost.\n\n\nSorry for the extra noise\n\nThanks,\nDanh\n"},{"id":"400869","messageId":"pull.781.v5.git.git.1593587206520.gitgitgadget@gmail.com","threadId":"53430","inReplyTo":"pull.781.v4.git.git.1593516397380.gitgitgadget@gmail.com","subject":"[PATCH v5] Enable auto-merge for meld to follow the vim-diff beharior","fromName":"sunlin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-07-01T07:06:46Z","receivedAt":"2020-07-01T07:06:51Z","isPatch":true,"sender":{"key":"name:sunlin","avatar":null},"body":"From: Lin Sun <lin.sun@zoom.us>\n\nMake the mergetool used with \"meld\" backend behave similarly to\nhow \"vimdiff\" behavior by telling it to auto-merge parts without\nconflicts and highlight the parts with conflicts when configuring\n`mergetool.meld.hasAutoMerge` with `true`, or `auto` for\nautomatically detecting the option.\n\nSigned-off-by: Lin Sun <lin.sun@zoom.us>\n---\n    Enable auto-merge for meld to follow the vimdiff beharior\n    \n    Hi, the mergetool \"meld\" does NOT merge the no-conflict changes, while\n    the mergetool \"vimdiff\" will merge the no-conflict changes and highlight\n    the conflict parts. This patch will make the mergetool \"meld\" similar to\n    \"vimdiff\", auto-merge the no-conflict changes, highlight conflict parts.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-781%2Fsunlin7%2Fmaster-v5\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-781/sunlin7/master-v5\nPull-Request: https://github.com/git/git/pull/781\n\nRange-diff vs v4:\n\n 1:  93ae3ec011 ! 1:  344817d579 Enable auto-merge for meld to follow the vim-diff beharior\n     @@\n       ## Metadata ##\n     -Author: lin.sun <lin.sun@zoom.us>\n     +Author: Lin Sun <lin.sun@zoom.us>\n      \n       ## Commit message ##\n          Enable auto-merge for meld to follow the vim-diff beharior\n      \n          Make the mergetool used with \"meld\" backend behave similarly to\n     -    how \"vimdiff\" beheaves by telling it to auto-merge parts without\n     -    conflicts and highlight the parts with conflicts.\n     +    how \"vimdiff\" behavior by telling it to auto-merge parts without\n     +    conflicts and highlight the parts with conflicts when configuring\n     +    `mergetool.meld.hasAutoMerge` with `true`, or `auto` for\n     +    automatically detecting the option.\n      \n     -    Signed-off-by: lin.sun <lin.sun@zoom.us>\n     +    Signed-off-by: Lin Sun <lin.sun@zoom.us>\n     +\n     + ## Documentation/config/mergetool.txt ##\n     +@@ Documentation/config/mergetool.txt: mergetool.meld.hasOutput::\n     + \tto `true` tells Git to unconditionally use the `--output` option,\n     + \tand `false` avoids using `--output`.\n     + \n     ++mergetool.meld.hasAutoMerge::\n     ++\tOlder versions of `meld` do not support the `--auto-merge` option.\n     ++\tSetting `mergetool.meld.hasOutput` to `true` tells Git to\n     ++\tunconditionally use the `--auto-merge` option, and `false` avoids using\n     ++\t`--auto-merge`, and `auto` detect whether `meld` supports `--auto-merge`\n     ++\tby inspecting the output of `meld --help`, otherwise, follow meld's\n     ++\tdefault behavior.\n     ++\n     + mergetool.keepBackup::\n     + \tAfter performing a merge, the original file with conflict markers\n     + \tcan be saved as a file with a `.orig` extension.  If this variable\n      \n       ## mergetools/meld ##\n      @@ mergetools/meld: diff_cmd () {\n     @@ mergetools/meld: diff_cmd () {\n      +# Get meld help message\n      +get_meld_help_msg () {\n      +\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n     -+  $meld_path --help 2>&1\n     ++\t$meld_path --help 2>&1\n      +}\n       \n      -\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n     @@ mergetools/meld: diff_cmd () {\n      -\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n      +\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n      +\t\tif test \"$meld_has_output_option\" = true -o \\\n     -+\t\t\t\t\t\t\"$meld_has_output_option\" = false\n     ++\t\t\t\"$meld_has_output_option\" = false\n      +\t\tthen\n      +\t\t\t: use configured value\n     -+\t\telse\t\t\t\t\t\t\t\t\t\t\t\t# treat meld_has_output_option as \"auto\"\n     ++\t\telse\n     ++\t\t\t# treat meld_has_output_option as \"auto\"\n      +\t\t\tif test -z \"$meld_help_msg\"\n      +\t\t\tthen\n      +\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n      +\t\t\tfi\n      +\n     -+\t\t\tif echo \"$meld_help_msg\" |\n     -+\t\t\t\t\t\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n     -+\t\t\tthen\n     -+\t\t\t\t: old ones mention --output and new ones just say OPTION...\n     -+\t\t\t\tmeld_has_output_option=true\n     -+\t\t\telse\n     -+\t\t\t\tmeld_has_output_option=false\n     -+\t\t\tfi\n     ++\t\t\tcase \"$meld_help_msg\" in\n     ++\t\t\t\t*\"--output=\"* | *\"[OPTION\"???\"]\"*)\n     ++\t\t\t\t\t# old ones mention --output and new ones just say OPTION...\n     ++\t\t\t\t\tmeld_has_output_option=true ;;\n     ++\t\t\t\t*)\n     ++\t\t\t\t\tmeld_has_output_option=false ;;\n     ++\t\t\tesac\n      +\t\tfi\n      +\tfi\n      +\t# Check whether we should use 'meld --auto-merge ...'\n     @@ mergetools/meld: diff_cmd () {\n      -\t\tmeld_has_output_option=true\n      -\telse\n      -\t\tmeld_has_output_option=false\n     -+\t\tmeld_has_auto_merge_option=$(git config --bool mergetool.meld.hasAutoMerge)\n     -+\t\tif test \"$meld_has_auto_merge_option\" = true -o \\\n     -+\t\t\t\t\t\t\"$meld_has_auto_merge_option\" = false\n     ++\t\tmeld_has_auto_merge_option=$(git config mergetool.meld.hasAutoMerge)\n     ++\t\tif test \"$meld_has_auto_merge_option\" = auto\n      +\t\tthen\n     -+\t\t\t: use configured value\n     -+\t\telse\t\t\t\t\t\t\t\t\t\t\t\t# treat meld_has_auto_merge_option as \"auto\"\n     ++\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n      +\t\t\tif test -z \"$meld_help_msg\"\n      +\t\t\tthen\n      +\t\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n      +\t\t\tfi\n      +\n     -+\t\t\tif echo \"$meld_help_msg\" | grep -e '--auto-merge' >/dev/null\n     -+\t\t\tthen\n     -+\t\t\t\t\tmeld_has_auto_merge_option=true\n     -+\t\t\telse\n     -+\t\t\t\tmeld_has_auto_merge_option=false\n     -+\t\t\tfi\n     ++\t\t\tcase \"$meld_help_msg\" in\n     ++\t\t\t\t*\"--auto-merge\"*)\n     ++\t\t\t\t\t: old ones mention --output and new ones just say OPTION...\n     ++\t\t\t\t\tmeld_has_auto_merge_option=true ;;\n     ++\t\t\t\t*)\n     ++\t\t\t\t\tmeld_has_auto_merge_option=false ;;\n     ++\t\t\tesac\n      +\t\tfi\n       \tfi\n       }\n\n\n Documentation/config/mergetool.txt |  8 ++++\n mergetools/meld                    | 72 +++++++++++++++++++++++-------\n 2 files changed, 64 insertions(+), 16 deletions(-)\n\ndiff --git a/Documentation/config/mergetool.txt b/Documentation/config/mergetool.txt\nindex 09ed31dbfa..9a74bd98dc 100644\n--- a/Documentation/config/mergetool.txt\n+++ b/Documentation/config/mergetool.txt\n@@ -30,6 +30,14 @@ mergetool.meld.hasOutput::\n \tto `true` tells Git to unconditionally use the `--output` option,\n \tand `false` avoids using `--output`.\n \n+mergetool.meld.hasAutoMerge::\n+\tOlder versions of `meld` do not support the `--auto-merge` option.\n+\tSetting `mergetool.meld.hasOutput` to `true` tells Git to\n+\tunconditionally use the `--auto-merge` option, and `false` avoids using\n+\t`--auto-merge`, and `auto` detect whether `meld` supports `--auto-merge`\n+\tby inspecting the output of `meld --help`, otherwise, follow meld's\n+\tdefault behavior.\n+\n mergetool.keepBackup::\n \tAfter performing a merge, the original file with conflict markers\n \tcan be saved as a file with a `.orig` extension.  If this variable\ndiff --git a/mergetools/meld b/mergetools/meld\nindex 7a08470f88..9ee835b1e5 100644\n--- a/mergetools/meld\n+++ b/mergetools/meld\n@@ -3,34 +3,74 @@ diff_cmd () {\n }\n \n merge_cmd () {\n-\tif test -z \"${meld_has_output_option:+set}\"\n+\tcheck_meld_for_features\n+\n+\toption_auto_merge=\n+\tif test \"$meld_has_auto_merge_option\" = true\n \tthen\n-\t\tcheck_meld_for_output_version\n+\t\toption_auto_merge=\"--auto-merge\"\n \tfi\n \n \tif test \"$meld_has_output_option\" = true\n \tthen\n-\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n+\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \telse\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \tfi\n }\n \n-# Check whether we should use 'meld --output <file>'\n-check_meld_for_output_version () {\n-\tmeld_path=\"$(git config mergetool.meld.path)\"\n-\tmeld_path=\"${meld_path:-meld}\"\n+# Get meld help message\n+get_meld_help_msg () {\n+\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n+\t$meld_path --help 2>&1\n+}\n \n-\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+# Check the features and set flags\n+check_meld_for_features () {\n+\t# Check whether we should use 'meld --output <file>'\n+\tif test -z \"${meld_has_output_option:+set}\"\n \tthen\n-\t\t: use configured value\n-\telif \"$meld_path\" --help 2>&1 |\n-\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n+\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+\t\tif test \"$meld_has_output_option\" = true -o \\\n+\t\t\t\"$meld_has_output_option\" = false\n+\t\tthen\n+\t\t\t: use configured value\n+\t\telse\n+\t\t\t# treat meld_has_output_option as \"auto\"\n+\t\t\tif test -z \"$meld_help_msg\"\n+\t\t\tthen\n+\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n+\t\t\tfi\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t\t*\"--output=\"* | *\"[OPTION\"???\"]\"*)\n+\t\t\t\t\t# old ones mention --output and new ones just say OPTION...\n+\t\t\t\t\tmeld_has_output_option=true ;;\n+\t\t\t\t*)\n+\t\t\t\t\tmeld_has_output_option=false ;;\n+\t\t\tesac\n+\t\tfi\n+\tfi\n+\t# Check whether we should use 'meld --auto-merge ...'\n+\tif test -z \"${meld_has_auto_merge_option:+set}\"\n \tthen\n-\t\t: old ones mention --output and new ones just say OPTION...\n-\t\tmeld_has_output_option=true\n-\telse\n-\t\tmeld_has_output_option=false\n+\t\tmeld_has_auto_merge_option=$(git config mergetool.meld.hasAutoMerge)\n+\t\tif test \"$meld_has_auto_merge_option\" = auto\n+\t\tthen\n+\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n+\t\t\tif test -z \"$meld_help_msg\"\n+\t\t\tthen\n+\t\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n+\t\t\tfi\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t\t*\"--auto-merge\"*)\n+\t\t\t\t\t: old ones mention --output and new ones just say OPTION...\n+\t\t\t\t\tmeld_has_auto_merge_option=true ;;\n+\t\t\t\t*)\n+\t\t\t\t\tmeld_has_auto_merge_option=false ;;\n+\t\t\tesac\n+\t\tfi\n \tfi\n }\n\nbase-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n-- \ngitgitgadget\n"},{"id":"400870","messageId":"1514701d64f78$970ba180$c522e480$@zoom.us","threadId":"53430","inReplyTo":"pull.781.v5.git.git.1593587206520.gitgitgadget@gmail.com","subject":"RE: [PATCH v5] Enable auto-merge for meld to follow the vim-diff beharior","fromName":"","fromEmail":"lin.sun@zoom.us","sentAt":"2020-07-01T07:23:56Z","receivedAt":"2020-07-01T07:24:05Z","isPatch":true,"sender":{"key":"lin.sun@zoom.us","avatar":null},"body":"Hi Danh,\n\nThe [PATH v5] is changed to following the comments from you, Junio, David. \nPlease review this newer version. Thank you.\nThe raw files is https://github.com/git/git/blob/344817d57970e3ac0910cdd8ad47bf97334ab2a6/mergetools/meld\n\nRegards\nLin\n-----Original Message-----\nFrom: sunlin via GitGitGadget <gitgitgadget@gmail.com> \nSent: Wednesday, July 1, 2020 15:07\nTo: git@vger.kernel.org\nCc: sunlin <sunlin7@yahoo.com>; Lin Sun <lin.sun@zoom.us>\nSubject: [PATCH v5] Enable auto-merge for meld to follow the vim-diff beharior\n\nFrom: Lin Sun <lin.sun@zoom.us>\n\nMake the mergetool used with \"meld\" backend behave similarly to how \"vimdiff\" behavior by telling it to auto-merge parts without conflicts and highlight the parts with conflicts when configuring `mergetool.meld.hasAutoMerge` with `true`, or `auto` for automatically detecting the option.\n\nSigned-off-by: Lin Sun <lin.sun@zoom.us>\n---\n    Enable auto-merge for meld to follow the vimdiff beharior\n    \n    Hi, the mergetool \"meld\" does NOT merge the no-conflict changes, while\n    the mergetool \"vimdiff\" will merge the no-conflict changes and highlight\n    the conflict parts. This patch will make the mergetool \"meld\" similar to\n    \"vimdiff\", auto-merge the no-conflict changes, highlight conflict parts.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-781%2Fsunlin7%2Fmaster-v5\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-781/sunlin7/master-v5\nPull-Request: https://github.com/git/git/pull/781\n\nRange-diff vs v4:\n\n 1:  93ae3ec011 ! 1:  344817d579 Enable auto-merge for meld to follow the vim-diff beharior\n     @@\n       ## Metadata ##\n     -Author: lin.sun <lin.sun@zoom.us>\n     +Author: Lin Sun <lin.sun@zoom.us>\n      \n       ## Commit message ##\n          Enable auto-merge for meld to follow the vim-diff beharior\n      \n          Make the mergetool used with \"meld\" backend behave similarly to\n     -    how \"vimdiff\" beheaves by telling it to auto-merge parts without\n     -    conflicts and highlight the parts with conflicts.\n     +    how \"vimdiff\" behavior by telling it to auto-merge parts without\n     +    conflicts and highlight the parts with conflicts when configuring\n     +    `mergetool.meld.hasAutoMerge` with `true`, or `auto` for\n     +    automatically detecting the option.\n      \n     -    Signed-off-by: lin.sun <lin.sun@zoom.us>\n     +    Signed-off-by: Lin Sun <lin.sun@zoom.us>\n     +\n     + ## Documentation/config/mergetool.txt ##\n     +@@ Documentation/config/mergetool.txt: mergetool.meld.hasOutput::\n     + \tto `true` tells Git to unconditionally use the `--output` option,\n     + \tand `false` avoids using `--output`.\n     + \n     ++mergetool.meld.hasAutoMerge::\n     ++\tOlder versions of `meld` do not support the `--auto-merge` option.\n     ++\tSetting `mergetool.meld.hasOutput` to `true` tells Git to\n     ++\tunconditionally use the `--auto-merge` option, and `false` avoids using\n     ++\t`--auto-merge`, and `auto` detect whether `meld` supports `--auto-merge`\n     ++\tby inspecting the output of `meld --help`, otherwise, follow meld's\n     ++\tdefault behavior.\n     ++\n     + mergetool.keepBackup::\n     + \tAfter performing a merge, the original file with conflict markers\n     + \tcan be saved as a file with a `.orig` extension.  If this variable\n      \n       ## mergetools/meld ##\n      @@ mergetools/meld: diff_cmd () {\n     @@ mergetools/meld: diff_cmd () {\n      +# Get meld help message\n      +get_meld_help_msg () {\n      +\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n     -+  $meld_path --help 2>&1\n     ++\t$meld_path --help 2>&1\n      +}\n       \n      -\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n     @@ mergetools/meld: diff_cmd () {\n      -\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n      +\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n      +\t\tif test \"$meld_has_output_option\" = true -o \\\n     -+\t\t\t\t\t\t\"$meld_has_output_option\" = false\n     ++\t\t\t\"$meld_has_output_option\" = false\n      +\t\tthen\n      +\t\t\t: use configured value\n     -+\t\telse\t\t\t\t\t\t\t\t\t\t\t\t# treat meld_has_output_option as \"auto\"\n     ++\t\telse\n     ++\t\t\t# treat meld_has_output_option as \"auto\"\n      +\t\t\tif test -z \"$meld_help_msg\"\n      +\t\t\tthen\n      +\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n      +\t\t\tfi\n      +\n     -+\t\t\tif echo \"$meld_help_msg\" |\n     -+\t\t\t\t\t\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n     -+\t\t\tthen\n     -+\t\t\t\t: old ones mention --output and new ones just say OPTION...\n     -+\t\t\t\tmeld_has_output_option=true\n     -+\t\t\telse\n     -+\t\t\t\tmeld_has_output_option=false\n     -+\t\t\tfi\n     ++\t\t\tcase \"$meld_help_msg\" in\n     ++\t\t\t\t*\"--output=\"* | *\"[OPTION\"???\"]\"*)\n     ++\t\t\t\t\t# old ones mention --output and new ones just say OPTION...\n     ++\t\t\t\t\tmeld_has_output_option=true ;;\n     ++\t\t\t\t*)\n     ++\t\t\t\t\tmeld_has_output_option=false ;;\n     ++\t\t\tesac\n      +\t\tfi\n      +\tfi\n      +\t# Check whether we should use 'meld --auto-merge ...'\n     @@ mergetools/meld: diff_cmd () {\n      -\t\tmeld_has_output_option=true\n      -\telse\n      -\t\tmeld_has_output_option=false\n     -+\t\tmeld_has_auto_merge_option=$(git config --bool mergetool.meld.hasAutoMerge)\n     -+\t\tif test \"$meld_has_auto_merge_option\" = true -o \\\n     -+\t\t\t\t\t\t\"$meld_has_auto_merge_option\" = false\n     ++\t\tmeld_has_auto_merge_option=$(git config mergetool.meld.hasAutoMerge)\n     ++\t\tif test \"$meld_has_auto_merge_option\" = auto\n      +\t\tthen\n     -+\t\t\t: use configured value\n     -+\t\telse\t\t\t\t\t\t\t\t\t\t\t\t# treat meld_has_auto_merge_option as \"auto\"\n     ++\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n      +\t\t\tif test -z \"$meld_help_msg\"\n      +\t\t\tthen\n      +\t\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n      +\t\t\tfi\n      +\n     -+\t\t\tif echo \"$meld_help_msg\" | grep -e '--auto-merge' >/dev/null\n     -+\t\t\tthen\n     -+\t\t\t\t\tmeld_has_auto_merge_option=true\n     -+\t\t\telse\n     -+\t\t\t\tmeld_has_auto_merge_option=false\n     -+\t\t\tfi\n     ++\t\t\tcase \"$meld_help_msg\" in\n     ++\t\t\t\t*\"--auto-merge\"*)\n     ++\t\t\t\t\t: old ones mention --output and new ones just say OPTION...\n     ++\t\t\t\t\tmeld_has_auto_merge_option=true ;;\n     ++\t\t\t\t*)\n     ++\t\t\t\t\tmeld_has_auto_merge_option=false ;;\n     ++\t\t\tesac\n      +\t\tfi\n       \tfi\n       }\n\n\n Documentation/config/mergetool.txt |  8 ++++\n mergetools/meld                    | 72 +++++++++++++++++++++++-------\n 2 files changed, 64 insertions(+), 16 deletions(-)\n\ndiff --git a/Documentation/config/mergetool.txt b/Documentation/config/mergetool.txt\nindex 09ed31dbfa..9a74bd98dc 100644\n--- a/Documentation/config/mergetool.txt\n+++ b/Documentation/config/mergetool.txt\n@@ -30,6 +30,14 @@ mergetool.meld.hasOutput::\n \tto `true` tells Git to unconditionally use the `--output` option,\n \tand `false` avoids using `--output`.\n \n+mergetool.meld.hasAutoMerge::\n+\tOlder versions of `meld` do not support the `--auto-merge` option.\n+\tSetting `mergetool.meld.hasOutput` to `true` tells Git to\n+\tunconditionally use the `--auto-merge` option, and `false` avoids using\n+\t`--auto-merge`, and `auto` detect whether `meld` supports `--auto-merge`\n+\tby inspecting the output of `meld --help`, otherwise, follow meld's\n+\tdefault behavior.\n+\n mergetool.keepBackup::\n \tAfter performing a merge, the original file with conflict markers\n \tcan be saved as a file with a `.orig` extension.  If this variable diff --git a/mergetools/meld b/mergetools/meld index 7a08470f88..9ee835b1e5 100644\n--- a/mergetools/meld\n+++ b/mergetools/meld\n@@ -3,34 +3,74 @@ diff_cmd () {\n }\n \n merge_cmd () {\n-\tif test -z \"${meld_has_output_option:+set}\"\n+\tcheck_meld_for_features\n+\n+\toption_auto_merge=\n+\tif test \"$meld_has_auto_merge_option\" = true\n \tthen\n-\t\tcheck_meld_for_output_version\n+\t\toption_auto_merge=\"--auto-merge\"\n \tfi\n \n \tif test \"$meld_has_output_option\" = true\n \tthen\n-\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n+\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \telse\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \tfi\n }\n \n-# Check whether we should use 'meld --output <file>'\n-check_meld_for_output_version () {\n-\tmeld_path=\"$(git config mergetool.meld.path)\"\n-\tmeld_path=\"${meld_path:-meld}\"\n+# Get meld help message\n+get_meld_help_msg () {\n+\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n+\t$meld_path --help 2>&1\n+}\n \n-\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+# Check the features and set flags\n+check_meld_for_features () {\n+\t# Check whether we should use 'meld --output <file>'\n+\tif test -z \"${meld_has_output_option:+set}\"\n \tthen\n-\t\t: use configured value\n-\telif \"$meld_path\" --help 2>&1 |\n-\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n+\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+\t\tif test \"$meld_has_output_option\" = true -o \\\n+\t\t\t\"$meld_has_output_option\" = false\n+\t\tthen\n+\t\t\t: use configured value\n+\t\telse\n+\t\t\t# treat meld_has_output_option as \"auto\"\n+\t\t\tif test -z \"$meld_help_msg\"\n+\t\t\tthen\n+\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n+\t\t\tfi\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t\t*\"--output=\"* | *\"[OPTION\"???\"]\"*)\n+\t\t\t\t\t# old ones mention --output and new ones just say OPTION...\n+\t\t\t\t\tmeld_has_output_option=true ;;\n+\t\t\t\t*)\n+\t\t\t\t\tmeld_has_output_option=false ;;\n+\t\t\tesac\n+\t\tfi\n+\tfi\n+\t# Check whether we should use 'meld --auto-merge ...'\n+\tif test -z \"${meld_has_auto_merge_option:+set}\"\n \tthen\n-\t\t: old ones mention --output and new ones just say OPTION...\n-\t\tmeld_has_output_option=true\n-\telse\n-\t\tmeld_has_output_option=false\n+\t\tmeld_has_auto_merge_option=$(git config mergetool.meld.hasAutoMerge)\n+\t\tif test \"$meld_has_auto_merge_option\" = auto\n+\t\tthen\n+\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n+\t\t\tif test -z \"$meld_help_msg\"\n+\t\t\tthen\n+\t\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n+\t\t\tfi\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t\t*\"--auto-merge\"*)\n+\t\t\t\t\t: old ones mention --output and new ones just say OPTION...\n+\t\t\t\t\tmeld_has_auto_merge_option=true ;;\n+\t\t\t\t*)\n+\t\t\t\t\tmeld_has_auto_merge_option=false ;;\n+\t\t\tesac\n+\t\tfi\n \tfi\n }\n\nbase-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n--\ngitgitgadget\n\n"},{"id":"400919","messageId":"20200701141755.GB1966@danh.dev","threadId":"53430","inReplyTo":"pull.781.v5.git.git.1593587206520.gitgitgadget@gmail.com","subject":"Re: [PATCH v5] Enable auto-merge for meld to follow the vim-diff beharior","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-07-01T14:17:55Z","receivedAt":"2020-07-01T14:18:00Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-07-01 07:06:46+0000, sunlin via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> From: Lin Sun <lin.sun@zoom.us>\n> \n> Make the mergetool used with \"meld\" backend behave similarly to\n> how \"vimdiff\" behavior by telling it to auto-merge parts without\n> conflicts and highlight the parts with conflicts when configuring\n> `mergetool.meld.hasAutoMerge` with `true`, or `auto` for\n> automatically detecting the option.\n> \n> Signed-off-by: Lin Sun <lin.sun@zoom.us>\n> ---\n> diff --git a/Documentation/config/mergetool.txt b/Documentation/config/mergetool.txt\n> index 09ed31dbfa..9a74bd98dc 100644\n> --- a/Documentation/config/mergetool.txt\n> +++ b/Documentation/config/mergetool.txt\n> @@ -30,6 +30,14 @@ mergetool.meld.hasOutput::\n>  \tto `true` tells Git to unconditionally use the `--output` option,\n>  \tand `false` avoids using `--output`.\n>  \n> +mergetool.meld.hasAutoMerge::\n> +\tOlder versions of `meld` do not support the `--auto-merge` option.\n> +\tSetting `mergetool.meld.hasOutput` to `true` tells Git to\n\ns/hasOutput/hasAutoMerge/\n\nBikeshed opinion: I don't know if hasAutoMerge is a good name :)\n\n> +\tunconditionally use the `--auto-merge` option, and `false` avoids using\n> +\t`--auto-merge`, and `auto` detect whether `meld` supports `--auto-merge`\n> +\tby inspecting the output of `meld --help`, otherwise, follow meld's\n> +\tdefault behavior.\n> +\n>  mergetool.keepBackup::\n>  \tAfter performing a merge, the original file with conflict markers\n>  \tcan be saved as a file with a `.orig` extension.  If this variable\n> diff --git a/mergetools/meld b/mergetools/meld\n> index 7a08470f88..9ee835b1e5 100644\n> --- a/mergetools/meld\n> +++ b/mergetools/meld\n> @@ -3,34 +3,74 @@ diff_cmd () {\n>  }\n>  \n>  merge_cmd () {\n> -\tif test -z \"${meld_has_output_option:+set}\"\n> +\tcheck_meld_for_features\n> +\n> +\toption_auto_merge=\n> +\tif test \"$meld_has_auto_merge_option\" = true\n>  \tthen\n> -\t\tcheck_meld_for_output_version\n> +\t\toption_auto_merge=\"--auto-merge\"\n>  \tfi\n>  \n>  \tif test \"$meld_has_output_option\" = true\n>  \tthen\n> -\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n> +\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n>  \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n>  \telse\n> -\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n> +\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n>  \tfi\n>  }\n>  \n> -# Check whether we should use 'meld --output <file>'\n> -check_meld_for_output_version () {\n> -\tmeld_path=\"$(git config mergetool.meld.path)\"\n> -\tmeld_path=\"${meld_path:-meld}\"\n> +# Get meld help message\n> +get_meld_help_msg () {\n> +\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n> +\t$meld_path --help 2>&1\n> +}\n\nI'm actually prefer this change in 2 separated patches to reduce noise.\nBut given that mergetool/meld doesn't attract much attention, I don't know.\n\n>  \n> -\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n> +# Check the features and set flags\n> +check_meld_for_features () {\n> +\t# Check whether we should use 'meld --output <file>'\n> +\tif test -z \"${meld_has_output_option:+set}\"\n>  \tthen\n> -\t\t: use configured value\n> -\telif \"$meld_path\" --help 2>&1 |\n> -\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n> +\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n> +\t\tif test \"$meld_has_output_option\" = true -o \\\n> +\t\t\t\"$meld_has_output_option\" = false\n\nThe coding guideline seems to not like \"test -o\".\nI think it's acceptable in this case since we control its input.\nThe output is comming out of \"git config --bool\" anyway,\nso meld_has_output_option must be either \"\", \"true\", or \"false\"\n\nI think we're better to do this instead:\n\n\tif test -n \"$meld_has_output_option\"\n\tthen\n\t\t: use configured output\n\telse\n\t\t: messing with help\n\tfi\n\n> +\t\tthen\n> +\t\t\t: use configured value\n> +\t\telse\n> +\t\t\t# treat meld_has_output_option as \"auto\"\n> +\t\t\tif test -z \"$meld_help_msg\"\n> +\t\t\tthen\n> +\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n> +\t\t\tfi\n\nIf I were writing this patch, I probably changed get_meld_help_msg to\n\n\tinit_meld_help_msg () {\n\t\tif test -z \"$meld_help_msg\"\n\t\tthen\n\t\t\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n\t\t\tmeld_help_msg=$($meld_path --help 2>&1)\n\t\tfi\n\t}\n\nAnd call init_meld_help_msg unconditionally here,\n(and in --auto-merge arm below, maybe other arms in the future).\n\nI'm writing without much thought into this,\nplease take my word with a grain of salt :)\n\n> +}\n\n\n> +\n> +\t\t\tcase \"$meld_help_msg\" in\n> +\t\t\t\t*\"--output=\"* | *\"[OPTION\"???\"]\"*)\n\nI think Git project prefer aligning case arm with case,\nIOW, move left 1 TAB.\n\n> +\t\t\t\t\t# old ones mention --output and new ones just say OPTION...\n> +\t\t\t\t\tmeld_has_output_option=true ;;\n\nIt's nice to see this update, good.\nThe comment is no longer correct, though.\nThe version 3.20.2 has --output but not OPTIONS.\n\nIt's not introduced by your change, but I think it's better to say:\n\n\t# All versions that has [OPTIONS???] supports --output\n\n> +\t\t\t\t*)\n> +\t\t\t\t\tmeld_has_output_option=false ;;\n> +\t\t\tesac\n> +\t\tfi\n> +\tfi\n> +\t# Check whether we should use 'meld --auto-merge ...'\n> +\tif test -z \"${meld_has_auto_merge_option:+set}\"\n>  \tthen\n> -\t\t: old ones mention --output and new ones just say OPTION...\n> -\t\tmeld_has_output_option=true\n> -\telse\n> -\t\tmeld_has_output_option=false\n> +\t\tmeld_has_auto_merge_option=$(git config mergetool.meld.hasAutoMerge)\n> +\t\tif test \"$meld_has_auto_merge_option\" = auto\n\nSince we don't canonicallise to bool output of\nmergetool.meld.hasAutoMerge, I think we would need:\n\n\tcase \"$meld_has_auto_merge_option\" in\n\t[Tt]rue|[Yy]es|[Oo]n)\n\t\tmeld_has_auto_merge_option=true ;;\n\tauto)\n\t\t: this shenanigan ;;\n\tesac\n\nBut, that's a bit messy. Let's see other's opinions.\n\n> +\t\tthen\n> +\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n> +\t\t\tif test -z \"$meld_help_msg\"\n> +\t\t\tthen\n> +\t\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n> +\t\t\tfi\n> +\n> +\t\t\tcase \"$meld_help_msg\" in\n> +\t\t\t\t*\"--auto-merge\"*)\n> +\t\t\t\t\t: old ones mention --output and new ones just say OPTION...\n\nThis comment doesn't apply here.\n\n> +\t\t\t\t\tmeld_has_auto_merge_option=true ;;\n> +\t\t\t\t*)\n> +\t\t\t\t\tmeld_has_auto_merge_option=false ;;\n> +\t\t\tesac\n> +\t\tfi\n>  \tfi\n>  }\n> \n> base-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n> -- \n> gitgitgadget\n\n-- \nDanh\n"},{"id":"400925","messageId":"1764101d64fbc$ccf9d7a0$66ed86e0$@zoom.us","threadId":"53430","inReplyTo":"20200701141755.GB1966@danh.dev","subject":"RE: [PATCH v5] Enable auto-merge for meld to follow the vim-diff beharior","fromName":"","fromEmail":"lin.sun@zoom.us","sentAt":"2020-07-01T15:32:11Z","receivedAt":"2020-07-01T15:32:21Z","isPatch":true,"sender":{"key":"lin.sun@zoom.us","avatar":null},"body":"Hi Danh,\n\nThank you for your comments, and changes apply to the last patch with your suggestions. Please refer the attachment for [PATH v6].\nThank you.\n\nRegards\nLin \n\n-----Original Message-----\nFrom: Đoàn Trần Công Danh <congdanhqx@gmail.com> \nSent: Wednesday, July 1, 2020 22:18\nTo: sunlin via GitGitGadget <gitgitgadget@gmail.com>\nCc: git@vger.kernel.org; sunlin <sunlin7@yahoo.com>; Lin Sun <lin.sun@zoom.us>\nSubject: Re: [PATCH v5] Enable auto-merge for meld to follow the vim-diff beharior\n\nOn 2020-07-01 07:06:46+0000, sunlin via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> From: Lin Sun <lin.sun@zoom.us>\n> \n> Make the mergetool used with \"meld\" backend behave similarly to how \n> \"vimdiff\" behavior by telling it to auto-merge parts without conflicts \n> and highlight the parts with conflicts when configuring \n> `mergetool.meld.hasAutoMerge` with `true`, or `auto` for automatically \n> detecting the option.\n> \n> Signed-off-by: Lin Sun <lin.sun@zoom.us>\n> ---\n> diff --git a/Documentation/config/mergetool.txt \n> b/Documentation/config/mergetool.txt\n> index 09ed31dbfa..9a74bd98dc 100644\n> --- a/Documentation/config/mergetool.txt\n> +++ b/Documentation/config/mergetool.txt\n> @@ -30,6 +30,14 @@ mergetool.meld.hasOutput::\n>  \tto `true` tells Git to unconditionally use the `--output` option,\n>  \tand `false` avoids using `--output`.\n>  \n> +mergetool.meld.hasAutoMerge::\n> +\tOlder versions of `meld` do not support the `--auto-merge` option.\n> +\tSetting `mergetool.meld.hasOutput` to `true` tells Git to\n\ns/hasOutput/hasAutoMerge/\n\nBikeshed opinion: I don't know if hasAutoMerge is a good name :)\n\n> +\tunconditionally use the `--auto-merge` option, and `false` avoids using\n> +\t`--auto-merge`, and `auto` detect whether `meld` supports `--auto-merge`\n> +\tby inspecting the output of `meld --help`, otherwise, follow meld's\n> +\tdefault behavior.\n> +\n>  mergetool.keepBackup::\n>  \tAfter performing a merge, the original file with conflict markers\n>  \tcan be saved as a file with a `.orig` extension.  If this variable \n> diff --git a/mergetools/meld b/mergetools/meld index \n> 7a08470f88..9ee835b1e5 100644\n> --- a/mergetools/meld\n> +++ b/mergetools/meld\n> @@ -3,34 +3,74 @@ diff_cmd () {\n>  }\n>  \n>  merge_cmd () {\n> -\tif test -z \"${meld_has_output_option:+set}\"\n> +\tcheck_meld_for_features\n> +\n> +\toption_auto_merge=\n> +\tif test \"$meld_has_auto_merge_option\" = true\n>  \tthen\n> -\t\tcheck_meld_for_output_version\n> +\t\toption_auto_merge=\"--auto-merge\"\n>  \tfi\n>  \n>  \tif test \"$meld_has_output_option\" = true\n>  \tthen\n> -\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n> +\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n>  \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n>  \telse\n> -\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n> +\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n>  \tfi\n>  }\n>  \n> -# Check whether we should use 'meld --output <file>'\n> -check_meld_for_output_version () {\n> -\tmeld_path=\"$(git config mergetool.meld.path)\"\n> -\tmeld_path=\"${meld_path:-meld}\"\n> +# Get meld help message\n> +get_meld_help_msg () {\n> +\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n> +\t$meld_path --help 2>&1\n> +}\n\nI'm actually prefer this change in 2 separated patches to reduce noise.\nBut given that mergetool/meld doesn't attract much attention, I don't know.\n\n>  \n> -\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n> +# Check the features and set flags\n> +check_meld_for_features () {\n> +\t# Check whether we should use 'meld --output <file>'\n> +\tif test -z \"${meld_has_output_option:+set}\"\n>  \tthen\n> -\t\t: use configured value\n> -\telif \"$meld_path\" --help 2>&1 |\n> -\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n> +\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n> +\t\tif test \"$meld_has_output_option\" = true -o \\\n> +\t\t\t\"$meld_has_output_option\" = false\n\nThe coding guideline seems to not like \"test -o\".\nI think it's acceptable in this case since we control its input.\nThe output is comming out of \"git config --bool\" anyway, so meld_has_output_option must be either \"\", \"true\", or \"false\"\n\nI think we're better to do this instead:\n\n\tif test -n \"$meld_has_output_option\"\n\tthen\n\t\t: use configured output\n\telse\n\t\t: messing with help\n\tfi\n\n> +\t\tthen\n> +\t\t\t: use configured value\n> +\t\telse\n> +\t\t\t# treat meld_has_output_option as \"auto\"\n> +\t\t\tif test -z \"$meld_help_msg\"\n> +\t\t\tthen\n> +\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n> +\t\t\tfi\n\nIf I were writing this patch, I probably changed get_meld_help_msg to\n\n\tinit_meld_help_msg () {\n\t\tif test -z \"$meld_help_msg\"\n\t\tthen\n\t\t\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n\t\t\tmeld_help_msg=$($meld_path --help 2>&1)\n\t\tfi\n\t}\n\nAnd call init_meld_help_msg unconditionally here, (and in --auto-merge arm below, maybe other arms in the future).\n\nI'm writing without much thought into this, please take my word with a grain of salt :)\n\n> +}\n\n\n> +\n> +\t\t\tcase \"$meld_help_msg\" in\n> +\t\t\t\t*\"--output=\"* | *\"[OPTION\"???\"]\"*)\n\nI think Git project prefer aligning case arm with case, IOW, move left 1 TAB.\n\n> +\t\t\t\t\t# old ones mention --output and new ones just say OPTION...\n> +\t\t\t\t\tmeld_has_output_option=true ;;\n\nIt's nice to see this update, good.\nThe comment is no longer correct, though.\nThe version 3.20.2 has --output but not OPTIONS.\n\nIt's not introduced by your change, but I think it's better to say:\n\n\t# All versions that has [OPTIONS???] supports --output\n\n> +\t\t\t\t*)\n> +\t\t\t\t\tmeld_has_output_option=false ;;\n> +\t\t\tesac\n> +\t\tfi\n> +\tfi\n> +\t# Check whether we should use 'meld --auto-merge ...'\n> +\tif test -z \"${meld_has_auto_merge_option:+set}\"\n>  \tthen\n> -\t\t: old ones mention --output and new ones just say OPTION...\n> -\t\tmeld_has_output_option=true\n> -\telse\n> -\t\tmeld_has_output_option=false\n> +\t\tmeld_has_auto_merge_option=$(git config mergetool.meld.hasAutoMerge)\n> +\t\tif test \"$meld_has_auto_merge_option\" = auto\n\nSince we don't canonicallise to bool output of mergetool.meld.hasAutoMerge, I think we would need:\n\n\tcase \"$meld_has_auto_merge_option\" in\n\t[Tt]rue|[Yy]es|[Oo]n)\n\t\tmeld_has_auto_merge_option=true ;;\n\tauto)\n\t\t: this shenanigan ;;\n\tesac\n\nBut, that's a bit messy. Let's see other's opinions.\n\n> +\t\tthen\n> +\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n> +\t\t\tif test -z \"$meld_help_msg\"\n> +\t\t\tthen\n> +\t\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n> +\t\t\tfi\n> +\n> +\t\t\tcase \"$meld_help_msg\" in\n> +\t\t\t\t*\"--auto-merge\"*)\n> +\t\t\t\t\t: old ones mention --output and new ones just say OPTION...\n\nThis comment doesn't apply here.\n\n> +\t\t\t\t\tmeld_has_auto_merge_option=true ;;\n> +\t\t\t\t*)\n> +\t\t\t\t\tmeld_has_auto_merge_option=false ;;\n> +\t\t\tesac\n> +\t\tfi\n>  \tfi\n>  }\n> \n> base-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n> --\n> gitgitgadget\n\n--\nDanh\n\n\nFrom 33968fb9e52a6ead7b9fc64943d4c82c3f893865 Mon Sep 17 00:00:00 2001\nFrom: Lin Sun <lin.sun@zoom.us>\nDate: Thu, 7 May 2020 07:31:14 +0800\nSubject: [PATCH] Enable auto-merge for meld to follow the vim-diff beharior\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n\nMake the mergetool used with \"meld\" backend behave similarly to\nhow \"vimdiff\" behavior by telling it to auto-merge parts without\nconflicts and highlight the parts with conflicts when configuring\n`mergetool.meld.hasAutoMerge` with `true`, or `auto` for\nautomatically detecting the option.\n\nHelped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\nSigned-off-by: Lin Sun <lin.sun@zoom.us>\n---\n Documentation/config/mergetool.txt |  8 ++++\n mergetools/meld                    | 80 ++++++++++++++++++++++++++++++--------\n 2 files changed, 72 insertions(+), 16 deletions(-)\n\ndiff --git a/Documentation/config/mergetool.txt b/Documentation/config/mergetool.txt\nindex 09ed31d..d2af88c 100644\n--- a/Documentation/config/mergetool.txt\n+++ b/Documentation/config/mergetool.txt\n@@ -30,6 +30,14 @@ mergetool.meld.hasOutput::\n \tto `true` tells Git to unconditionally use the `--output` option,\n \tand `false` avoids using `--output`.\n \n+mergetool.meld.hasAutoMerge::\n+\tOlder versions of `meld` do not support the `--auto-merge` option.\n+\tSetting `mergetool.meld.hasAutoMerge` to `true` tells Git to\n+\tunconditionally use the `--auto-merge` option, and `false` avoids using\n+\t`--auto-merge`, and `auto` detect whether `meld` supports `--auto-merge`\n+\tby inspecting the output of `meld --help`, otherwise, follow meld's\n+\tdefault behavior.\n+\n mergetool.keepBackup::\n \tAfter performing a merge, the original file with conflict markers\n \tcan be saved as a file with a `.orig` extension.  If this variable\ndiff --git a/mergetools/meld b/mergetools/meld\nindex 7a08470..c6f499d 100644\n--- a/mergetools/meld\n+++ b/mergetools/meld\n@@ -3,34 +3,82 @@ diff_cmd () {\n }\n \n merge_cmd () {\n-\tif test -z \"${meld_has_output_option:+set}\"\n+\tcheck_meld_for_features\n+\n+\toption_auto_merge=\n+\tif test \"$meld_has_auto_merge_option\" = true\n \tthen\n-\t\tcheck_meld_for_output_version\n+\t\toption_auto_merge=\"--auto-merge\"\n \tfi\n \n \tif test \"$meld_has_output_option\" = true\n \tthen\n-\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n+\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \telse\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \tfi\n }\n \n-# Check whether we should use 'meld --output <file>'\n-check_meld_for_output_version () {\n-\tmeld_path=\"$(git config mergetool.meld.path)\"\n-\tmeld_path=\"${meld_path:-meld}\"\n+# Get meld help message\n+init_meld_help_msg () {\n+\tif test -z \"${meld_help_msg:+set}\"\n+\tthen\n+\t\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n+\t\tmeld_help_msg=$($meld_path --help 2>&1)\n+\tfi\n+}\n \n-\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+# Check the features and set flags\n+check_meld_for_features () {\n+\t# Check whether we should use 'meld --output <file>'\n+\tif test -z \"${meld_has_output_option:+set}\"\n \tthen\n-\t\t: use configured value\n-\telif \"$meld_path\" --help 2>&1 |\n-\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n+\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+\t\tcase \"$meld_has_output_option\" in\n+\t\ttrue|false)\n+\t\t\t: use configured value\n+\t\t\t;;\n+\t\t*)\n+\t\t\t: treat meld_has_output_option as \"auto\"\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--output=\"* | *\"[OPTION\"???\"]\"*)\n+\t\t\t\t# All version that has [OPTION???] supports --output\n+\t\t\t\tmeld_has_output_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_has_output_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\tesac\n+\tfi\n+\t# Check whether we should use 'meld --auto-merge ...'\n+\tif test -z \"${meld_has_auto_merge_option:+set}\"\n \tthen\n-\t\t: old ones mention --output and new ones just say OPTION...\n-\t\tmeld_has_output_option=true\n-\telse\n-\t\tmeld_has_output_option=false\n+\t\tmeld_has_auto_merge_option=$(git config mergetool.meld.hasAutoMerge)\n+\t\tcase \"$meld_has_auto_merge_option\" in\n+\t\t[Tt]rue|[Yy]es|[Oo]n|1)\n+\t\t\tmeld_has_auto_merge_option=true\n+\t\t\t;;\n+\t\tauto)\n+\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--auto-merge\"*)\n+\t\t\t\tmeld_has_auto_merge_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_has_auto_merge_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\t*)\n+\t\t\tmeld_has_auto_merge_option=false\n+\t\t\t;;\n+\t\tesac\n \tfi\n }\n-- \n2.2.0\n\n"},{"id":"400939","messageId":"20200701181947.GA16794@gmail.com","threadId":"53430","inReplyTo":"1514701d64f78$970ba180$c522e480$@zoom.us","subject":"Re: [PATCH v5] Enable auto-merge for meld to follow the vim-diff beharior","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2020-07-01T18:19:47Z","receivedAt":"2020-07-01T18:19:53Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Wed, Jul 01, 2020 at 03:23:56PM +0800, lin.sun@zoom.us wrote:\n> Hi Danh,\n> \n> The [PATH v5] is changed to following the comments from you, Junio, David. \n> Please review this newer version. Thank you.\n> The raw files is https://github.com/git/git/blob/344817d57970e3ac0910cdd8ad47bf97334ab2a6/mergetools/meld\n> \n> Regards\n> Lin\n> -----Original Message-----\n> From: sunlin via GitGitGadget <gitgitgadget@gmail.com> \n> Sent: Wednesday, July 1, 2020 15:07\n> To: git@vger.kernel.org\n> Cc: sunlin <sunlin7@yahoo.com>; Lin Sun <lin.sun@zoom.us>\n> Subject: [PATCH v5] Enable auto-merge for meld to follow the vim-diff beharior\n> \n> From: Lin Sun <lin.sun@zoom.us>\n> \n> Make the mergetool used with \"meld\" backend behave similarly to how \"vimdiff\" behavior by telling it to auto-merge parts without conflicts and highlight the parts with conflicts when configuring `mergetool.meld.hasAutoMerge` with `true`, or `auto` for automatically detecting the option.\n\nPlease word-wrap commit messages to 72 chars or less.\n\n\n> \n> Signed-off-by: Lin Sun <lin.sun@zoom.us>\n> ---\n>  Documentation/config/mergetool.txt |  8 ++++\n>  mergetools/meld                    | 72 +++++++++++++++++++++++-------\n>  2 files changed, 64 insertions(+), 16 deletions(-)\n> \n> diff --git a/Documentation/config/mergetool.txt b/Documentation/config/mergetool.txt\n> index 09ed31dbfa..9a74bd98dc 100644\n> --- a/Documentation/config/mergetool.txt\n> +++ b/Documentation/config/mergetool.txt\n> @@ -30,6 +30,14 @@ mergetool.meld.hasOutput::\n>  \tto `true` tells Git to unconditionally use the `--output` option,\n>  \tand `false` avoids using `--output`.\n>  \n> +mergetool.meld.hasAutoMerge::\n> +\tOlder versions of `meld` do not support the `--auto-merge` option.\n> +\tSetting `mergetool.meld.hasOutput` to `true` tells Git to\n> +\tunconditionally use the `--auto-merge` option, and `false` avoids using\n> +\t`--auto-merge`, and `auto` detect whether `meld` supports `--auto-merge`\n> +\tby inspecting the output of `meld --help`, otherwise, follow meld's\n> +\tdefault behavior.\n> +\n\nNow that we've decided that \"false\" should be the default behavior, the\nnaming of this option don't make sense.  \"hasAutoMerge\" doesn't\nreally convey what this option does anymore.  I would suggest calling it\n\"mergetool.meld.automerge\".\n\nPerhaps something like this?\n\nmergetool.meld.automerge::\n\tOlder versions of `meld` do not support the `--auto-merge`\n\toption.  Setting `mergetool.meld.automerge` to `true` tells Git\n\tto unconditionally use the `--auto-merge` option with `meld`.\n\tSetting this value to `auto` makes git detect whether\n\t`--auto-merge` is supported and will only use `--auto-merge`\n\twhen available.  A value of `false` avoids using `--auto-merge`\n\taltogether, and is the default value.\n\n> @@ -3,34 +3,74 @@ diff_cmd () {\n>  }\n>  \n>  merge_cmd () {\n> -\tif test -z \"${meld_has_output_option:+set}\"\n> +\tcheck_meld_for_features\n> +\n> +\toption_auto_merge=\n> +\tif test \"$meld_has_auto_merge_option\" = true\n>  \tthen\n> -\t\tcheck_meld_for_output_version\n> +\t\toption_auto_merge=\"--auto-merge\"\n>  \tfi\n>  \n>  \tif test \"$meld_has_output_option\" = true\n>  \tthen\n> -\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n> +\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n>  \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n>  \telse\n> -\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n> +\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n>  \tfi\n>  }\n>  \n> -# Check whether we should use 'meld --output <file>'\n> -check_meld_for_output_version () {\n> -\tmeld_path=\"$(git config mergetool.meld.path)\"\n> -\tmeld_path=\"${meld_path:-meld}\"\n> +# Get meld help message\n> +get_meld_help_msg () {\n\nThis comment seems redundant when the function is called\nget_meld_help_msg().\n\n\n> +\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n> +\t$meld_path --help 2>&1\n> +}\n>  \n> -\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n> +# Check the features and set flags\n> +check_meld_for_features () {\n\nDitto for this comment.\n\n\n> +\t# Check whether we should use 'meld --output <file>'\n> +\tif test -z \"${meld_has_output_option:+set}\"\n>  \tthen\n> -\t\t: use configured value\n> -\telif \"$meld_path\" --help 2>&1 |\n> -\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n> +\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n> +\t\tif test \"$meld_has_output_option\" = true -o \\\n> +\t\t\t\"$meld_has_output_option\" = false\n\nDocumentation/CodingGuidelines mentions:\n\n - We do not write our \"test\" command with \"-a\" and \"-o\" and use \"&&\"\n   or \"||\" to concatenate multiple \"test\" commands instead, because\n   the use of \"-a/-o\" is often error-prone.  E.g.\n\nThis would be written as:\n\n\tif test \"$meld_has_output_option\" = true ||\n\t\ttest \"$meld_has_output_option\" = false\n\tthen\n\t\t...\n\tfi\n\nInstead of two checks, would it be better to instead just check:\n\tif test -n \"$meld_has_output_option\"\n?\ngit config --bool will only ever produce true/false, so we really only\nneed to check that it's a non-empty value, perhaps?\n\n\n> +\t\t\tcase \"$meld_help_msg\" in\n> +\t\t\t\t*\"--output=\"* | *\"[OPTION\"???\"]\"*)\n> +\t\t\t\t\t# old ones mention --output and new ones just say OPTION...\n> +\t\t\t\t\tmeld_has_output_option=true ;;\n> +\t\t\t\t*)\n> +\t\t\t\t\tmeld_has_output_option=false ;;\n> +\t\t\tesac\n\nWe typically avoid the extra indentation level for the case labels.\neg. this would be written like this (with \";;\" on its own line):\n\n\tcase \"$meld_help_msg\" in\n\t*--output=*|*\"[OPTION\"???\"]\"*)\n\t\t# old ones mention --output and new ones just say OPTION...\n\t\tmeld_has_output_option=true\n\t\t;;\n\t*)\n\t\tmeld_has_output_option=false\n\t\t;;\n\tesac\n\n\nAlso, if you're matching [OPTION ...] would it work to just use\na single-quoted value in the case label?  eg: *'[OPTION...]'* ?\n\n\n> +\tif test -z \"${meld_has_auto_merge_option:+set}\"\n>  \tthen\n> -\t\t: old ones mention --output and new ones just say OPTION...\n> -\t\tmeld_has_output_option=true\n> -\telse\n> -\t\tmeld_has_output_option=false\n> +\t\tmeld_has_auto_merge_option=$(git config mergetool.meld.hasAutoMerge)\n> +\t\tif test \"$meld_has_auto_merge_option\" = auto\n> +\t\tthen\n> +\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n> +\t\t\tif test -z \"$meld_help_msg\"\n> +\t\t\tthen\n> +\t\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n\nThis can just be:\n\n\tmeld_help_msg=$(get_meld_help_msg)\n\nand can do without the surrounding \" \" double quotes.\n\n\n\n> +\t\t\tcase \"$meld_help_msg\" in\n> +\t\t\t\t*\"--auto-merge\"*)\n> +\t\t\t\t\t: old ones mention --output and new ones just say OPTION...\n> +\t\t\t\t\tmeld_has_auto_merge_option=true ;;\n> +\t\t\t\t*)\n> +\t\t\t\t\tmeld_has_auto_merge_option=false ;;\n> +\t\t\tesac\n\nAs above -- unindent the case statements, and put the \";;\" case\nstatement terminators on their own line.\n\ncheers,\n-- \nDavid\n"},{"id":"400941","messageId":"xmqq7dvndnf0.fsf@gitster.c.googlers.com","threadId":"53430","inReplyTo":"20200701141755.GB1966@danh.dev","subject":"Re: [PATCH v5] Enable auto-merge for meld to follow the vim-diff beharior","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-07-01T19:51:15Z","receivedAt":"2020-07-01T19:51:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Đoàn Trần Công Danh  <congdanhqx@gmail.com> writes:\n\n>> +mergetool.meld.hasAutoMerge::\n>> +\tOlder versions of `meld` do not support the `--auto-merge` option.\n>> +\tSetting `mergetool.meld.hasOutput` to `true` tells Git to\n>\n> s/hasOutput/hasAutoMerge/\n>\n> Bikeshed opinion: I don't know if hasAutoMerge is a good name :)\n\nI do not think \"has\" is a good choice for this one, even though\nhasOutput may very well be a good one for \"output\".  As the\nparagraph describes (below), this lets the user \"avoid\" using\n\"--auto-merge\", even if the version of \"meld\" the user has does have\nthe automerge capability.\n\nSo perhaps say \"mergetool.meld.useAutoMerge\"; that will let the users\nexpress exactly their wish---don't use it (false), do forcibly try\nto use it (true), or use it when able (auto).\n\n"},{"id":"400953","messageId":"17eba01d64ff3$50ea2de0$f2be89a0$@zoom.us","threadId":"53430","inReplyTo":"1764101d64fbc$ccf9d7a0$66ed86e0$@zoom.us","subject":"RE: [PATCH v5] Enable auto-merge for meld to follow the vim-diff beharior","fromName":"","fromEmail":"lin.sun@zoom.us","sentAt":"2020-07-01T22:02:27Z","receivedAt":"2020-07-01T22:02:34Z","isPatch":true,"sender":{"key":"lin.sun@zoom.us","avatar":null},"body":"Hi Danh,\n\nI'll push the patch to GitGitGadget so that it's will sending from the system mail. Sorry for this noise.\n\nRegards\nLin\n\n-----Original Message-----\nFrom: lin.sun@zoom.us <lin.sun@zoom.us> \nSent: Wednesday, July 1, 2020 23:32\nTo: 'Đoàn Trần Công Danh' <congdanhqx@gmail.com>; 'sunlin via GitGitGadget' <gitgitgadget@gmail.com>\nCc: git@vger.kernel.org; 'Lin Sun' <lin.sun@zoom.us>\nSubject: RE: [PATCH v5] Enable auto-merge for meld to follow the vim-diff beharior\n\nHi Danh,\n\nThank you for your comments, and changes apply to the last patch with your suggestions. Please refer the attachment for [PATH v6].\nThank you.\n\nRegards\nLin \n\n-----Original Message-----\nFrom: Đoàn Trần Công Danh <congdanhqx@gmail.com>\nSent: Wednesday, July 1, 2020 22:18\nTo: sunlin via GitGitGadget <gitgitgadget@gmail.com>\nCc: git@vger.kernel.org; sunlin <sunlin7@yahoo.com>; Lin Sun <lin.sun@zoom.us>\nSubject: Re: [PATCH v5] Enable auto-merge for meld to follow the vim-diff beharior\n\nOn 2020-07-01 07:06:46+0000, sunlin via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> From: Lin Sun <lin.sun@zoom.us>\n> \n> Make the mergetool used with \"meld\" backend behave similarly to how \n> \"vimdiff\" behavior by telling it to auto-merge parts without conflicts \n> and highlight the parts with conflicts when configuring \n> `mergetool.meld.hasAutoMerge` with `true`, or `auto` for automatically \n> detecting the option.\n> \n> Signed-off-by: Lin Sun <lin.sun@zoom.us>\n> ---\n> diff --git a/Documentation/config/mergetool.txt\n> b/Documentation/config/mergetool.txt\n> index 09ed31dbfa..9a74bd98dc 100644\n> --- a/Documentation/config/mergetool.txt\n> +++ b/Documentation/config/mergetool.txt\n> @@ -30,6 +30,14 @@ mergetool.meld.hasOutput::\n>  \tto `true` tells Git to unconditionally use the `--output` option,\n>  \tand `false` avoids using `--output`.\n>  \n> +mergetool.meld.hasAutoMerge::\n> +\tOlder versions of `meld` do not support the `--auto-merge` option.\n> +\tSetting `mergetool.meld.hasOutput` to `true` tells Git to\n\ns/hasOutput/hasAutoMerge/\n\nBikeshed opinion: I don't know if hasAutoMerge is a good name :)\n\n> +\tunconditionally use the `--auto-merge` option, and `false` avoids using\n> +\t`--auto-merge`, and `auto` detect whether `meld` supports `--auto-merge`\n> +\tby inspecting the output of `meld --help`, otherwise, follow meld's\n> +\tdefault behavior.\n> +\n>  mergetool.keepBackup::\n>  \tAfter performing a merge, the original file with conflict markers\n>  \tcan be saved as a file with a `.orig` extension.  If this variable \n> diff --git a/mergetools/meld b/mergetools/meld index\n> 7a08470f88..9ee835b1e5 100644\n> --- a/mergetools/meld\n> +++ b/mergetools/meld\n> @@ -3,34 +3,74 @@ diff_cmd () {\n>  }\n>  \n>  merge_cmd () {\n> -\tif test -z \"${meld_has_output_option:+set}\"\n> +\tcheck_meld_for_features\n> +\n> +\toption_auto_merge=\n> +\tif test \"$meld_has_auto_merge_option\" = true\n>  \tthen\n> -\t\tcheck_meld_for_output_version\n> +\t\toption_auto_merge=\"--auto-merge\"\n>  \tfi\n>  \n>  \tif test \"$meld_has_output_option\" = true\n>  \tthen\n> -\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n> +\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n>  \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n>  \telse\n> -\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n> +\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n>  \tfi\n>  }\n>  \n> -# Check whether we should use 'meld --output <file>'\n> -check_meld_for_output_version () {\n> -\tmeld_path=\"$(git config mergetool.meld.path)\"\n> -\tmeld_path=\"${meld_path:-meld}\"\n> +# Get meld help message\n> +get_meld_help_msg () {\n> +\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n> +\t$meld_path --help 2>&1\n> +}\n\nI'm actually prefer this change in 2 separated patches to reduce noise.\nBut given that mergetool/meld doesn't attract much attention, I don't know.\n\n>  \n> -\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n> +# Check the features and set flags\n> +check_meld_for_features () {\n> +\t# Check whether we should use 'meld --output <file>'\n> +\tif test -z \"${meld_has_output_option:+set}\"\n>  \tthen\n> -\t\t: use configured value\n> -\telif \"$meld_path\" --help 2>&1 |\n> -\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n> +\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n> +\t\tif test \"$meld_has_output_option\" = true -o \\\n> +\t\t\t\"$meld_has_output_option\" = false\n\nThe coding guideline seems to not like \"test -o\".\nI think it's acceptable in this case since we control its input.\nThe output is comming out of \"git config --bool\" anyway, so meld_has_output_option must be either \"\", \"true\", or \"false\"\n\nI think we're better to do this instead:\n\n\tif test -n \"$meld_has_output_option\"\n\tthen\n\t\t: use configured output\n\telse\n\t\t: messing with help\n\tfi\n\n> +\t\tthen\n> +\t\t\t: use configured value\n> +\t\telse\n> +\t\t\t# treat meld_has_output_option as \"auto\"\n> +\t\t\tif test -z \"$meld_help_msg\"\n> +\t\t\tthen\n> +\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n> +\t\t\tfi\n\nIf I were writing this patch, I probably changed get_meld_help_msg to\n\n\tinit_meld_help_msg () {\n\t\tif test -z \"$meld_help_msg\"\n\t\tthen\n\t\t\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n\t\t\tmeld_help_msg=$($meld_path --help 2>&1)\n\t\tfi\n\t}\n\nAnd call init_meld_help_msg unconditionally here, (and in --auto-merge arm below, maybe other arms in the future).\n\nI'm writing without much thought into this, please take my word with a grain of salt :)\n\n> +}\n\n\n> +\n> +\t\t\tcase \"$meld_help_msg\" in\n> +\t\t\t\t*\"--output=\"* | *\"[OPTION\"???\"]\"*)\n\nI think Git project prefer aligning case arm with case, IOW, move left 1 TAB.\n\n> +\t\t\t\t\t# old ones mention --output and new ones just say OPTION...\n> +\t\t\t\t\tmeld_has_output_option=true ;;\n\nIt's nice to see this update, good.\nThe comment is no longer correct, though.\nThe version 3.20.2 has --output but not OPTIONS.\n\nIt's not introduced by your change, but I think it's better to say:\n\n\t# All versions that has [OPTIONS???] supports --output\n\n> +\t\t\t\t*)\n> +\t\t\t\t\tmeld_has_output_option=false ;;\n> +\t\t\tesac\n> +\t\tfi\n> +\tfi\n> +\t# Check whether we should use 'meld --auto-merge ...'\n> +\tif test -z \"${meld_has_auto_merge_option:+set}\"\n>  \tthen\n> -\t\t: old ones mention --output and new ones just say OPTION...\n> -\t\tmeld_has_output_option=true\n> -\telse\n> -\t\tmeld_has_output_option=false\n> +\t\tmeld_has_auto_merge_option=$(git config mergetool.meld.hasAutoMerge)\n> +\t\tif test \"$meld_has_auto_merge_option\" = auto\n\nSince we don't canonicallise to bool output of mergetool.meld.hasAutoMerge, I think we would need:\n\n\tcase \"$meld_has_auto_merge_option\" in\n\t[Tt]rue|[Yy]es|[Oo]n)\n\t\tmeld_has_auto_merge_option=true ;;\n\tauto)\n\t\t: this shenanigan ;;\n\tesac\n\nBut, that's a bit messy. Let's see other's opinions.\n\n> +\t\tthen\n> +\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n> +\t\t\tif test -z \"$meld_help_msg\"\n> +\t\t\tthen\n> +\t\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n> +\t\t\tfi\n> +\n> +\t\t\tcase \"$meld_help_msg\" in\n> +\t\t\t\t*\"--auto-merge\"*)\n> +\t\t\t\t\t: old ones mention --output and new ones just say OPTION...\n\nThis comment doesn't apply here.\n\n> +\t\t\t\t\tmeld_has_auto_merge_option=true ;;\n> +\t\t\t\t*)\n> +\t\t\t\t\tmeld_has_auto_merge_option=false ;;\n> +\t\t\tesac\n> +\t\tfi\n>  \tfi\n>  }\n> \n> base-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n> --\n> gitgitgadget\n\n--\nDanh\n\n"},{"id":"400956","messageId":"20200701230647.GC1966@danh.dev","threadId":"53430","inReplyTo":"17eba01d64ff3$50ea2de0$f2be89a0$@zoom.us","subject":"Re: [PATCH v5] Enable auto-merge for meld to follow the vim-diff beharior","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-07-01T23:06:47Z","receivedAt":"2020-07-01T23:06:53Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-07-02 06:02:27+0800, lin.sun@zoom.us wrote:\n> Hi Danh,\n\nHi Lin,\n\n> \n> I'll push the patch to GitGitGadget so that it's will sending from\n> the system mail. Sorry for this noise.\n\nWhile you're doing it,\ndo you mind changing hasAutoMerge to useAutoMerge?\nI think that name is better :)\n\nc.f: https://lore.kernel.org/git/xmqq7dvndnf0.fsf@gitster.c.googlers.com/\n\nThanks,\n\n-- \nDanh\n"},{"id":"400957","messageId":"1830601d65006$957cac90$c07605b0$@zoom.us","threadId":"53430","inReplyTo":"xmqq7dvndnf0.fsf@gitster.c.googlers.com","subject":"RE: [PATCH v5] Enable auto-merge for meld to follow the vim-diff beharior","fromName":"","fromEmail":"lin.sun@zoom.us","sentAt":"2020-07-02T00:20:22Z","receivedAt":"2020-07-02T00:20:32Z","isPatch":true,"sender":{"key":"lin.sun@zoom.us","avatar":null},"body":"Hi Danh,\n\n> While you're doing it,\n> do you mind changing hasAutoMerge to useAutoMerge?\n> I think that name is better :)\nOkay, no problem, it will be ` useAutoMerge`.\n\nRegards\nLin\n\n"},{"id":"400958","messageId":"pull.781.v6.git.git.1593650687697.gitgitgadget@gmail.com","threadId":"53430","inReplyTo":"pull.781.v5.git.git.1593587206520.gitgitgadget@gmail.com","subject":"[PATCH v6] Support auto-merge for meld to follow the vim-diff behavior","fromName":"sunlin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-07-02T00:44:47Z","receivedAt":"2020-07-02T00:44:53Z","isPatch":true,"sender":{"key":"name:sunlin","avatar":null},"body":"From: Lin Sun <lin.sun@zoom.us>\n\nMake the mergetool used with \"meld\" backend behave similarly to how\n\"vimdiff\" behavior by telling it to auto-merge parts without conflicts\nand highlight the parts with conflicts when configuring\n`mergetool.meld.useAutoMerge` with `true`, or `auto` for automatically\ndetecting the option.\n\nHelped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\nHelped-by: Junio C Hamano <gitster@pobox.com>\nHelped-by: David Aguilar <davvid@gmail.com>\nSigned-off-by: Lin Sun <lin.sun@zoom.us>\n---\n    Enable auto-merge for meld to follow the vimdiff beharior\n    \n    Hi, the mergetool \"meld\" does NOT merge the no-conflict changes, while\n    the mergetool \"vimdiff\" will merge the no-conflict changes and highlight\n    the conflict parts. This patch will make the mergetool \"meld\" similar to\n    \"vimdiff\", auto-merge the no-conflict changes, highlight conflict parts.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-781%2Fsunlin7%2Fmaster-v6\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-781/sunlin7/master-v6\nPull-Request: https://github.com/git/git/pull/781\n\nRange-diff vs v5:\n\n 1:  344817d579 ! 1:  63ee3406d2 Enable auto-merge for meld to follow the vim-diff beharior\n     @@ Metadata\n      Author: Lin Sun <lin.sun@zoom.us>\n      \n       ## Commit message ##\n     -    Enable auto-merge for meld to follow the vim-diff beharior\n     +    Support auto-merge for meld to follow the vim-diff behavior\n      \n     -    Make the mergetool used with \"meld\" backend behave similarly to\n     -    how \"vimdiff\" behavior by telling it to auto-merge parts without\n     -    conflicts and highlight the parts with conflicts when configuring\n     -    `mergetool.meld.hasAutoMerge` with `true`, or `auto` for\n     -    automatically detecting the option.\n     +    Make the mergetool used with \"meld\" backend behave similarly to how\n     +    \"vimdiff\" behavior by telling it to auto-merge parts without conflicts\n     +    and highlight the parts with conflicts when configuring\n     +    `mergetool.meld.useAutoMerge` with `true`, or `auto` for automatically\n     +    detecting the option.\n      \n     +    Helped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\n     +    Helped-by: Junio C Hamano <gitster@pobox.com>\n     +    Helped-by: David Aguilar <davvid@gmail.com>\n          Signed-off-by: Lin Sun <lin.sun@zoom.us>\n      \n       ## Documentation/config/mergetool.txt ##\n     @@ Documentation/config/mergetool.txt: mergetool.meld.hasOutput::\n       \tto `true` tells Git to unconditionally use the `--output` option,\n       \tand `false` avoids using `--output`.\n       \n     -+mergetool.meld.hasAutoMerge::\n     ++mergetool.meld.useAutoMerge::\n      +\tOlder versions of `meld` do not support the `--auto-merge` option.\n     -+\tSetting `mergetool.meld.hasOutput` to `true` tells Git to\n     -+\tunconditionally use the `--auto-merge` option, and `false` avoids using\n     -+\t`--auto-merge`, and `auto` detect whether `meld` supports `--auto-merge`\n     -+\tby inspecting the output of `meld --help`, otherwise, follow meld's\n     -+\tdefault behavior.\n     ++\tSetting `mergetool.meld.useAutoMerge` to `true` tells Git to\n     ++\tunconditionally use the `--auto-merge` option with `meld`.  Setting\n     ++\tthis value to `auto` makes git detect whether `--auto-merge` is\n     ++\tsupported and will only use `--auto-merge` when available.  A value\n     ++\tof `false` avoids using `--auto-merge` altogether, and is the default\n     ++\tvalue.\n      +\n       mergetool.keepBackup::\n       \tAfter performing a merge, the original file with conflict markers\n     @@ mergetools/meld: diff_cmd () {\n      +\tcheck_meld_for_features\n      +\n      +\toption_auto_merge=\n     -+\tif test \"$meld_has_auto_merge_option\" = true\n     ++\tif test \"$meld_use_auto_merge_option\" = true\n       \tthen\n      -\t\tcheck_meld_for_output_version\n      +\t\toption_auto_merge=\"--auto-merge\"\n     @@ mergetools/meld: diff_cmd () {\n      -\tmeld_path=\"$(git config mergetool.meld.path)\"\n      -\tmeld_path=\"${meld_path:-meld}\"\n      +# Get meld help message\n     -+get_meld_help_msg () {\n     -+\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n     -+\t$meld_path --help 2>&1\n     ++init_meld_help_msg () {\n     ++\tif test -z \"${meld_help_msg:+set}\"\n     ++\tthen\n     ++\t\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n     ++\t\tmeld_help_msg=$($meld_path --help 2>&1)\n     ++\tfi\n      +}\n       \n      -\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n     @@ mergetools/meld: diff_cmd () {\n      -\telif \"$meld_path\" --help 2>&1 |\n      -\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n      +\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n     -+\t\tif test \"$meld_has_output_option\" = true -o \\\n     -+\t\t\t\"$meld_has_output_option\" = false\n     -+\t\tthen\n     ++\t\tcase \"$meld_has_output_option\" in\n     ++\t\ttrue|false)\n      +\t\t\t: use configured value\n     -+\t\telse\n     -+\t\t\t# treat meld_has_output_option as \"auto\"\n     -+\t\t\tif test -z \"$meld_help_msg\"\n     -+\t\t\tthen\n     -+\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n     -+\t\t\tfi\n     ++\t\t\t;;\n     ++\t\t*)\n     ++\t\t\t: treat meld_has_output_option as \"auto\"\n     ++\t\t\tinit_meld_help_msg\n      +\n      +\t\t\tcase \"$meld_help_msg\" in\n     -+\t\t\t\t*\"--output=\"* | *\"[OPTION\"???\"]\"*)\n     -+\t\t\t\t\t# old ones mention --output and new ones just say OPTION...\n     -+\t\t\t\t\tmeld_has_output_option=true ;;\n     -+\t\t\t\t*)\n     -+\t\t\t\t\tmeld_has_output_option=false ;;\n     ++\t\t\t*\"--output=\"* | *'[OPTION...]'*)\n     ++\t\t\t\t# All version that has [OPTION...] supports --output\n     ++\t\t\t\tmeld_has_output_option=true\n     ++\t\t\t\t;;\n     ++\t\t\t*)\n     ++\t\t\t\tmeld_has_output_option=false\n     ++\t\t\t\t;;\n      +\t\t\tesac\n     -+\t\tfi\n     ++\t\t\t;;\n     ++\t\tesac\n      +\tfi\n      +\t# Check whether we should use 'meld --auto-merge ...'\n     -+\tif test -z \"${meld_has_auto_merge_option:+set}\"\n     ++\tif test -z \"${meld_use_auto_merge_option:+set}\"\n       \tthen\n      -\t\t: old ones mention --output and new ones just say OPTION...\n      -\t\tmeld_has_output_option=true\n      -\telse\n      -\t\tmeld_has_output_option=false\n     -+\t\tmeld_has_auto_merge_option=$(git config mergetool.meld.hasAutoMerge)\n     -+\t\tif test \"$meld_has_auto_merge_option\" = auto\n     -+\t\tthen\n     ++\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n     ++\t\tcase \"$meld_use_auto_merge_option\" in\n     ++\t\t[Tt]rue|[Yy]es|[Oo]n|1)\n     ++\t\t\tmeld_use_auto_merge_option=true\n     ++\t\t\t;;\n     ++\t\tauto)\n      +\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n     -+\t\t\tif test -z \"$meld_help_msg\"\n     -+\t\t\tthen\n     -+\t\t\t\t\tmeld_help_msg=\"$(get_meld_help_msg)\"\n     -+\t\t\tfi\n     ++\t\t\tinit_meld_help_msg\n      +\n      +\t\t\tcase \"$meld_help_msg\" in\n     -+\t\t\t\t*\"--auto-merge\"*)\n     -+\t\t\t\t\t: old ones mention --output and new ones just say OPTION...\n     -+\t\t\t\t\tmeld_has_auto_merge_option=true ;;\n     -+\t\t\t\t*)\n     -+\t\t\t\t\tmeld_has_auto_merge_option=false ;;\n     ++\t\t\t*\"--auto-merge\"*)\n     ++\t\t\t\tmeld_use_auto_merge_option=true\n     ++\t\t\t\t;;\n     ++\t\t\t*)\n     ++\t\t\t\tmeld_use_auto_merge_option=false\n     ++\t\t\t\t;;\n      +\t\t\tesac\n     -+\t\tfi\n     ++\t\t\t;;\n     ++\t\t*)\n     ++\t\t\tmeld_use_auto_merge_option=false\n     ++\t\t\t;;\n     ++\t\tesac\n       \tfi\n       }\n\n\n Documentation/config/mergetool.txt |  9 ++++\n mergetools/meld                    | 80 ++++++++++++++++++++++++------\n 2 files changed, 73 insertions(+), 16 deletions(-)\n\ndiff --git a/Documentation/config/mergetool.txt b/Documentation/config/mergetool.txt\nindex 09ed31dbfa..625ad34230 100644\n--- a/Documentation/config/mergetool.txt\n+++ b/Documentation/config/mergetool.txt\n@@ -30,6 +30,15 @@ mergetool.meld.hasOutput::\n \tto `true` tells Git to unconditionally use the `--output` option,\n \tand `false` avoids using `--output`.\n \n+mergetool.meld.useAutoMerge::\n+\tOlder versions of `meld` do not support the `--auto-merge` option.\n+\tSetting `mergetool.meld.useAutoMerge` to `true` tells Git to\n+\tunconditionally use the `--auto-merge` option with `meld`.  Setting\n+\tthis value to `auto` makes git detect whether `--auto-merge` is\n+\tsupported and will only use `--auto-merge` when available.  A value\n+\tof `false` avoids using `--auto-merge` altogether, and is the default\n+\tvalue.\n+\n mergetool.keepBackup::\n \tAfter performing a merge, the original file with conflict markers\n \tcan be saved as a file with a `.orig` extension.  If this variable\ndiff --git a/mergetools/meld b/mergetools/meld\nindex 7a08470f88..5bc03f564a 100644\n--- a/mergetools/meld\n+++ b/mergetools/meld\n@@ -3,34 +3,82 @@ diff_cmd () {\n }\n \n merge_cmd () {\n-\tif test -z \"${meld_has_output_option:+set}\"\n+\tcheck_meld_for_features\n+\n+\toption_auto_merge=\n+\tif test \"$meld_use_auto_merge_option\" = true\n \tthen\n-\t\tcheck_meld_for_output_version\n+\t\toption_auto_merge=\"--auto-merge\"\n \tfi\n \n \tif test \"$meld_has_output_option\" = true\n \tthen\n-\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n+\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \telse\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \tfi\n }\n \n-# Check whether we should use 'meld --output <file>'\n-check_meld_for_output_version () {\n-\tmeld_path=\"$(git config mergetool.meld.path)\"\n-\tmeld_path=\"${meld_path:-meld}\"\n+# Get meld help message\n+init_meld_help_msg () {\n+\tif test -z \"${meld_help_msg:+set}\"\n+\tthen\n+\t\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n+\t\tmeld_help_msg=$($meld_path --help 2>&1)\n+\tfi\n+}\n \n-\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+# Check the features and set flags\n+check_meld_for_features () {\n+\t# Check whether we should use 'meld --output <file>'\n+\tif test -z \"${meld_has_output_option:+set}\"\n \tthen\n-\t\t: use configured value\n-\telif \"$meld_path\" --help 2>&1 |\n-\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n+\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+\t\tcase \"$meld_has_output_option\" in\n+\t\ttrue|false)\n+\t\t\t: use configured value\n+\t\t\t;;\n+\t\t*)\n+\t\t\t: treat meld_has_output_option as \"auto\"\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--output=\"* | *'[OPTION...]'*)\n+\t\t\t\t# All version that has [OPTION...] supports --output\n+\t\t\t\tmeld_has_output_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_has_output_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\tesac\n+\tfi\n+\t# Check whether we should use 'meld --auto-merge ...'\n+\tif test -z \"${meld_use_auto_merge_option:+set}\"\n \tthen\n-\t\t: old ones mention --output and new ones just say OPTION...\n-\t\tmeld_has_output_option=true\n-\telse\n-\t\tmeld_has_output_option=false\n+\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n+\t\tcase \"$meld_use_auto_merge_option\" in\n+\t\t[Tt]rue|[Yy]es|[Oo]n|1)\n+\t\t\tmeld_use_auto_merge_option=true\n+\t\t\t;;\n+\t\tauto)\n+\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--auto-merge\"*)\n+\t\t\t\tmeld_use_auto_merge_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_use_auto_merge_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\t*)\n+\t\t\tmeld_use_auto_merge_option=false\n+\t\t\t;;\n+\t\tesac\n \tfi\n }\n\nbase-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n-- \ngitgitgadget\n"},{"id":"400959","messageId":"18df901d65019$6492b8f0$2db82ad0$@zoom.us","threadId":"53430","inReplyTo":"pull.781.v6.git.git.1593650687697.gitgitgadget@gmail.com","subject":"RE: [PATCH v6] Support auto-merge for meld to follow the vim-diff behavior","fromName":"","fromEmail":"lin.sun@zoom.us","sentAt":"2020-07-02T02:35:00Z","receivedAt":"2020-07-02T02:35:09Z","isPatch":true,"sender":{"key":"lin.sun@zoom.us","avatar":null},"body":"Hi,\n\nThe [PATCH v6] changes to follow comments from Danh, Junio, David. \nPlease review again. Thank you all.\n\nhttps://lore.kernel.org/git/pull.781.v6.git.git.1593650687697.gitgitgadget@gmail.com/\n\nRegards\nLin\n\n\n\n"},{"id":"400992","messageId":"xmqqv9j5bc4o.fsf@gitster.c.googlers.com","threadId":"53430","inReplyTo":"pull.781.v6.git.git.1593650687697.gitgitgadget@gmail.com","subject":"Re: [PATCH v6] Support auto-merge for meld to follow the vim-diff behavior","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-07-03T01:50:15Z","receivedAt":"2020-07-03T01:50:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"sunlin via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Lin Sun <lin.sun@zoom.us>\n>\n> Make the mergetool used with \"meld\" backend behave similarly to how\n> \"vimdiff\" behavior by telling it to auto-merge parts without conflicts\n> and highlight the parts with conflicts when configuring\n> `mergetool.meld.useAutoMerge` with `true`, or `auto` for automatically\n> detecting the option.\n>\n> Helped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\n> Helped-by: Junio C Hamano <gitster@pobox.com>\n> Helped-by: David Aguilar <davvid@gmail.com>\n> Signed-off-by: Lin Sun <lin.sun@zoom.us>\n> ---\n\nThanks.\n\n> +mergetool.meld.useAutoMerge::\n> +\tOlder versions of `meld` do not support the `--auto-merge` option.\n\nI do not mind the above text at all, but I do not think it is the\nmost important point about this configuration option.  Are the\nreaders of this manual page, at least the subset of them who are\ninterested in using the meld backend, expected to know what 'meld'\nwould do when given (and not given) the `--auto-merge` option?\n\nAt least, what meld does with and without `--auto-merge` briefly is\nmore important, especially if your belief is that it is plausible\nthat most users would prefer to use it.  Something like (I am not a\n`meld` user, so everything I wrote after the first comma ',' in\nthese two paragraphs may be total rubbish---I am just writing these\nas an illustration to show the level of details necessary to help\nreaders decide if the option is for them)...\n\n    When meld is given `--auto-merge`, a part of the conflicted file\n    that was modified only by one side is automatically resolved to\n    take that change, and a part that was touched by both sides are\n    highlighted for manual conflict resolution.\n\n    Without `--auto-merge` option given, the automatic resolution\n    does not happen---all changes in the conflicted file are\n    highlighted for manual conflict resolution.\n\nOnly after that, telling them \"(even though you may want to use the\noption all the time) Older versions of `meld` do not support it\"\nbecomes relevant---for users with ancient versions of `meld`, the\noption, even if it is desirable, may not be available to them so it\nis worth warning them that they should not set it to 'true' blindly\nwithout checking with their version of `meld` first.\n\n> diff --git a/mergetools/meld b/mergetools/meld\n> index 7a08470f88..5bc03f564a 100644\n> --- a/mergetools/meld\n> +++ b/mergetools/meld\n> @@ -3,34 +3,82 @@ diff_cmd () {\n>  }\n>  \n>  merge_cmd () {\n> +\tcheck_meld_for_features\n> +\n> +\toption_auto_merge=\n> +\tif test \"$meld_use_auto_merge_option\" = true\n>  \tthen\n> +\t\toption_auto_merge=\"--auto-merge\"\n>  \tfi\n>  \n>  \tif test \"$meld_has_output_option\" = true\n>  \tthen\n> +\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n>  \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n>  \telse\n> +\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n>  \tfi\n>  }\n\nThat's straight-forward to follow.  Good.\n\n> +# Get meld help message\n> +init_meld_help_msg () {\n> +\tif test -z \"${meld_help_msg:+set}\"\n\nI suspect that you copied the pattern \n\n    if test -z \"${var:+set}\"\n\nfrom the original, but it looks rather strange.  \"${var:+set}\" means\n\"if $var is set to a non-empty string, give me 'set'; otherwise give\nme $var\".  And checking if that result is an empty string with \"-z\"\nwould mean you can safely write\n\n    if test -z \"$var\"\n\nno?  If you are \"set -u\" proofing, you might write \"${var-}\" instead\nof \"$var\" there, but that does not change the story all that much.\n\n> +\tthen\n> +\t\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n> +\t\tmeld_help_msg=$($meld_path --help 2>&1)\n> +\tfi\n> +}\n\nIn any case, the if/then/fi makes sure we'll ask `meld` only once,\nwhich is good.\n\n> +# Check the features and set flags\n> +check_meld_for_features () {\n> +\t# Check whether we should use 'meld --output <file>'\n> +\tif test -z \"${meld_has_output_option:+set}\"\n\nLikewise about \"test -z ${var:+set}\".\n\nSo, if we do not know yet, then...\n\n>  \tthen\n> +\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n\nWe ask \"config --bool\" and are prepared to see two primary cases, i.e.\n\n> +\t\tcase \"$meld_has_output_option\" in\n> +\t\ttrue|false)\n> +\t\t\t: use configured value\n\nIn this case, the user may have configured, so the variable already\nhas the right value.  Good.\n\n> +\t\t\t;;\n> +\t\t*)\n> +\t\t\t: treat meld_has_output_option as \"auto\"\n> +\t\t\tinit_meld_help_msg\n\nOtherwise, we ask `meld`.\n\n> +\t\t\tcase \"$meld_help_msg\" in\n> +\t\t\t*\"--output=\"* | *'[OPTION...]'*)\n> +\t\t\t\t# All version that has [OPTION...] supports --output\n\nVery good comment.\n\n> +\t\t\t\tmeld_has_output_option=true\n> +\t\t\t\t;;\n> +\t\t\t*)\n> +\t\t\t\tmeld_has_output_option=false\n> +\t\t\t\t;;\n> +\t\t\tesac\n> +\t\t\t;;\n> +\t\tesac\n> +\tfi\n\nNicely done up to this point.\n\n> +\t# Check whether we should use 'meld --auto-merge ...'\n> +\tif test -z \"${meld_use_auto_merge_option:+set}\"\n\nLikewise about \"test -z ${var:+set}\".\n\nSo, if we do not know yet, then...\n\n>  \tthen\n> +\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n> +\t\tcase \"$meld_use_auto_merge_option\" in\n> +\t\t[Tt]rue|[Yy]es|[Oo]n|1)\n> +\t\t\tmeld_use_auto_merge_option=true\n\nThis is sloppy.  TRUE is also a valid way to spell 'yes'.\n\n    if o=$(git config --bool 2>/dev/null mergetool.meld.useautomerge)\n    then\n    \tmeld_use_auto_merge_option=$o\n    elif test auto = \"$(git config mergetool.meld.useautomerge)\"\n    then\n\t... auto detect ...\n    else\n\tmeld_use_auto_merge_option=false\n    fi\n\nMaybe somebody else has a clever idea to reduce the two calls into\none without breaking correctness, but unfortunately I do not offhand\nthink of a way to do this with just a single \"git config\" call.\n\n> +\t\t\t;;\n> +\t\tauto)\n> +\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n> +\t\t\tinit_meld_help_msg\n> +\n> +\t\t\tcase \"$meld_help_msg\" in\n> +\t\t\t*\"--auto-merge\"*)\n> +\t\t\t\tmeld_use_auto_merge_option=true\n> +\t\t\t\t;;\n> +\t\t\t*)\n> +\t\t\t\tmeld_use_auto_merge_option=false\n> +\t\t\t\t;;\n> +\t\t\tesac\n> +\t\t\t;;\n> +\t\t*)\n> +\t\t\tmeld_use_auto_merge_option=false\n> +\t\t\t;;\n> +\t\tesac\n>  \tfi\n>  }\n\nThanks.\n"},{"id":"400993","messageId":"pull.781.v7.git.git.1593746805771.gitgitgadget@gmail.com","threadId":"53430","inReplyTo":"pull.781.v6.git.git.1593650687697.gitgitgadget@gmail.com","subject":"[PATCH v7] Support auto-merge for meld to follow the vim-diff behavior","fromName":"sunlin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-07-03T03:26:45Z","receivedAt":"2020-07-03T03:26:50Z","isPatch":true,"sender":{"key":"name:sunlin","avatar":null},"body":"From: Lin Sun <lin.sun@zoom.us>\n\nMake the mergetool used with \"meld\" backend behave similarly to\n\"vimdiff\" by telling it to auto-merge non-conflicting parts and\nhighlight the conflicting parts when `mergetool.meld.useAutoMerge` is\nconfigured with `true`, or `auto` for detecting the `--auto-merge`\noption automatically.\n\nHelped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\nHelped-by: Junio C Hamano <gitster@pobox.com>\nHelped-by: David Aguilar <davvid@gmail.com>\nSigned-off-by: Lin Sun <lin.sun@zoom.us>\n---\n    Enable auto-merge for meld to follow the vimdiff beharior\n    \n    Hi, the mergetool \"meld\" does NOT merge the no-conflict changes, while\n    the mergetool \"vimdiff\" will merge the no-conflict changes and highlight\n    the conflict parts. This patch will make the mergetool \"meld\" similar to\n    \"vimdiff\", auto-merge the no-conflict changes, highlight conflict parts.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-781%2Fsunlin7%2Fmaster-v7\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-781/sunlin7/master-v7\nPull-Request: https://github.com/git/git/pull/781\n\nRange-diff vs v6:\n\n 1:  63ee3406d2 ! 1:  ec2b49b9b8 Support auto-merge for meld to follow the vim-diff behavior\n     @@ Metadata\n       ## Commit message ##\n          Support auto-merge for meld to follow the vim-diff behavior\n      \n     -    Make the mergetool used with \"meld\" backend behave similarly to how\n     -    \"vimdiff\" behavior by telling it to auto-merge parts without conflicts\n     -    and highlight the parts with conflicts when configuring\n     -    `mergetool.meld.useAutoMerge` with `true`, or `auto` for automatically\n     -    detecting the option.\n     +    Make the mergetool used with \"meld\" backend behave similarly to\n     +    \"vimdiff\" by telling it to auto-merge non-conflicting parts and\n     +    highlight the conflicting parts when `mergetool.meld.useAutoMerge` is\n     +    configured with `true`, or `auto` for detecting the `--auto-merge`\n     +    option automatically.\n      \n          Helped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\n          Helped-by: Junio C Hamano <gitster@pobox.com>\n     @@ Documentation/config/mergetool.txt: mergetool.meld.hasOutput::\n       \tand `false` avoids using `--output`.\n       \n      +mergetool.meld.useAutoMerge::\n     -+\tOlder versions of `meld` do not support the `--auto-merge` option.\n     -+\tSetting `mergetool.meld.useAutoMerge` to `true` tells Git to\n     -+\tunconditionally use the `--auto-merge` option with `meld`.  Setting\n     -+\tthis value to `auto` makes git detect whether `--auto-merge` is\n     -+\tsupported and will only use `--auto-merge` when available.  A value\n     -+\tof `false` avoids using `--auto-merge` altogether, and is the default\n     -+\tvalue.\n     ++\tWhen the `--auto-merge` is given, meld will merges all non-conflicting\n     ++\tpart automatically, highlight the conflicting part and waiting for user\n     ++\tdecision.  Setting `mergetool.meld.useAutoMerge` to `true` tells Git to\n     ++\tunconditionally use the `--auto-merge` option with `meld`.  Setting this\n     ++\tvalue to `auto` makes git detect whether `--auto-merge` is supported and\n     ++\twill only use `--auto-merge` when available.  A value of `false` avoids\n     ++\tusing `--auto-merge` altogether, and is the default value.\n      +\n       mergetool.keepBackup::\n       \tAfter performing a merge, the original file with conflict markers\n     @@ mergetools/meld: diff_cmd () {\n      -\tmeld_path=\"${meld_path:-meld}\"\n      +# Get meld help message\n      +init_meld_help_msg () {\n     -+\tif test -z \"${meld_help_msg:+set}\"\n     ++\tif test -z \"${meld_help_msg}\"\n      +\tthen\n      +\t\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n      +\t\tmeld_help_msg=$($meld_path --help 2>&1)\n     @@ mergetools/meld: diff_cmd () {\n      +# Check the features and set flags\n      +check_meld_for_features () {\n      +\t# Check whether we should use 'meld --output <file>'\n     -+\tif test -z \"${meld_has_output_option:+set}\"\n     ++\tif test -z \"${meld_has_output_option}\"\n       \tthen\n      -\t\t: use configured value\n      -\telif \"$meld_path\" --help 2>&1 |\n     @@ mergetools/meld: diff_cmd () {\n      +\t\t\t: use configured value\n      +\t\t\t;;\n      +\t\t*)\n     -+\t\t\t: treat meld_has_output_option as \"auto\"\n     ++\t\t\t: empty or invalid configured value, detecting \"--output\" automatically\n      +\t\t\tinit_meld_help_msg\n      +\n      +\t\t\tcase \"$meld_help_msg\" in\n     @@ mergetools/meld: diff_cmd () {\n      +\t\tesac\n      +\tfi\n      +\t# Check whether we should use 'meld --auto-merge ...'\n     -+\tif test -z \"${meld_use_auto_merge_option:+set}\"\n     ++\tif test -z \"${meld_use_auto_merge_option}\"\n       \tthen\n      -\t\t: old ones mention --output and new ones just say OPTION...\n      -\t\tmeld_has_output_option=true\n      -\telse\n      -\t\tmeld_has_output_option=false\n      +\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n     -+\t\tcase \"$meld_use_auto_merge_option\" in\n     -+\t\t[Tt]rue|[Yy]es|[Oo]n|1)\n     ++\t\tcase \"${meld_use_auto_merge_option,,*}\" in\n     ++\t\ttrue|yes|on|1)\n      +\t\t\tmeld_use_auto_merge_option=true\n      +\t\t\t;;\n      +\t\tauto)\n\n\n Documentation/config/mergetool.txt |  9 ++++\n mergetools/meld                    | 80 ++++++++++++++++++++++++------\n 2 files changed, 73 insertions(+), 16 deletions(-)\n\ndiff --git a/Documentation/config/mergetool.txt b/Documentation/config/mergetool.txt\nindex 09ed31dbfa..b7657734a0 100644\n--- a/Documentation/config/mergetool.txt\n+++ b/Documentation/config/mergetool.txt\n@@ -30,6 +30,15 @@ mergetool.meld.hasOutput::\n \tto `true` tells Git to unconditionally use the `--output` option,\n \tand `false` avoids using `--output`.\n \n+mergetool.meld.useAutoMerge::\n+\tWhen the `--auto-merge` is given, meld will merges all non-conflicting\n+\tpart automatically, highlight the conflicting part and waiting for user\n+\tdecision.  Setting `mergetool.meld.useAutoMerge` to `true` tells Git to\n+\tunconditionally use the `--auto-merge` option with `meld`.  Setting this\n+\tvalue to `auto` makes git detect whether `--auto-merge` is supported and\n+\twill only use `--auto-merge` when available.  A value of `false` avoids\n+\tusing `--auto-merge` altogether, and is the default value.\n+\n mergetool.keepBackup::\n \tAfter performing a merge, the original file with conflict markers\n \tcan be saved as a file with a `.orig` extension.  If this variable\ndiff --git a/mergetools/meld b/mergetools/meld\nindex 7a08470f88..5e6b50d480 100644\n--- a/mergetools/meld\n+++ b/mergetools/meld\n@@ -3,34 +3,82 @@ diff_cmd () {\n }\n \n merge_cmd () {\n-\tif test -z \"${meld_has_output_option:+set}\"\n+\tcheck_meld_for_features\n+\n+\toption_auto_merge=\n+\tif test \"$meld_use_auto_merge_option\" = true\n \tthen\n-\t\tcheck_meld_for_output_version\n+\t\toption_auto_merge=\"--auto-merge\"\n \tfi\n \n \tif test \"$meld_has_output_option\" = true\n \tthen\n-\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n+\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \telse\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \tfi\n }\n \n-# Check whether we should use 'meld --output <file>'\n-check_meld_for_output_version () {\n-\tmeld_path=\"$(git config mergetool.meld.path)\"\n-\tmeld_path=\"${meld_path:-meld}\"\n+# Get meld help message\n+init_meld_help_msg () {\n+\tif test -z \"${meld_help_msg}\"\n+\tthen\n+\t\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n+\t\tmeld_help_msg=$($meld_path --help 2>&1)\n+\tfi\n+}\n \n-\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+# Check the features and set flags\n+check_meld_for_features () {\n+\t# Check whether we should use 'meld --output <file>'\n+\tif test -z \"${meld_has_output_option}\"\n \tthen\n-\t\t: use configured value\n-\telif \"$meld_path\" --help 2>&1 |\n-\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n+\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+\t\tcase \"$meld_has_output_option\" in\n+\t\ttrue|false)\n+\t\t\t: use configured value\n+\t\t\t;;\n+\t\t*)\n+\t\t\t: empty or invalid configured value, detecting \"--output\" automatically\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--output=\"* | *'[OPTION...]'*)\n+\t\t\t\t# All version that has [OPTION...] supports --output\n+\t\t\t\tmeld_has_output_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_has_output_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\tesac\n+\tfi\n+\t# Check whether we should use 'meld --auto-merge ...'\n+\tif test -z \"${meld_use_auto_merge_option}\"\n \tthen\n-\t\t: old ones mention --output and new ones just say OPTION...\n-\t\tmeld_has_output_option=true\n-\telse\n-\t\tmeld_has_output_option=false\n+\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n+\t\tcase \"${meld_use_auto_merge_option,,*}\" in\n+\t\ttrue|yes|on|1)\n+\t\t\tmeld_use_auto_merge_option=true\n+\t\t\t;;\n+\t\tauto)\n+\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--auto-merge\"*)\n+\t\t\t\tmeld_use_auto_merge_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_use_auto_merge_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\t*)\n+\t\t\tmeld_use_auto_merge_option=false\n+\t\t\t;;\n+\t\tesac\n \tfi\n }\n\nbase-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n-- \ngitgitgadget\n"},{"id":"400999","messageId":"1f33d01d650ed$8f6069e0$ae213da0$@zoom.us","threadId":"53430","inReplyTo":"xmqqv9j5bc4o.fsf@gitster.c.googlers.com","subject":"RE: [PATCH v6] Support auto-merge for meld to follow the vim-diff behavior","fromName":"","fromEmail":"lin.sun@zoom.us","sentAt":"2020-07-03T03:53:45Z","receivedAt":"2020-07-03T03:53:53Z","isPatch":true,"sender":{"key":"lin.sun@zoom.us","avatar":null},"body":"Hi Junio,\n\nThank you for your comments, and the changes are made to follow your suggestion. \nIn the [PATCH v7], the \":+set\" is removed, and the \"${var,,*}\" is used to convert \nconfiguration to lower-case, it won't call git config twice for getting `useAutoMerge`.\n\nPlease review again, thank you.\nhttps://lore.kernel.org/git/pull.781.v7.git.git.1593746805771.gitgitgadget@gmail.com\n\nRegards\nLin\n\n\n"},{"id":"401001","messageId":"xmqqo8oxb3rv.fsf@gitster.c.googlers.com","threadId":"53430","inReplyTo":"pull.781.v7.git.git.1593746805771.gitgitgadget@gmail.com","subject":"Re: [PATCH v7] Support auto-merge for meld to follow the vim-diff behavior","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-07-03T04:50:44Z","receivedAt":"2020-07-03T04:50:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"sunlin via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n>      ++\tWhen the `--auto-merge` is given, meld will merges all non-conflicting\n\nGrammo: \"will merges\"???\n\n>      ++\tpart automatically, highlight the conflicting part and waiting for user\n>      ++\tdecision.  Setting `mergetool.meld.useAutoMerge` to `true` tells Git to\n>      ++\tunconditionally use the `--auto-merge` option with `meld`.  Setting this\n>      ++\tvalue to `auto` makes git detect whether `--auto-merge` is supported and\n>      ++\twill only use `--auto-merge` when available.  A value of `false` avoids\n>      ++\tusing `--auto-merge` altogether, and is the default value.\n>       +\n>        mergetool.keepBackup::\n>        \tAfter performing a merge, the original file with conflict markers\n>      @@ mergetools/meld: diff_cmd () {\n>       -\tmeld_path=\"${meld_path:-meld}\"\n>       +# Get meld help message\n>       +init_meld_help_msg () {\n>      -+\tif test -z \"${meld_help_msg:+set}\"\n>      ++\tif test -z \"${meld_help_msg}\"\n\nNow we do not use the :+ magic, there is no reason to use extra\n{brace} around the variable name.  Just sticking to the normal\n\"$meld_help_msg\" would help the readers to hint that there is no\nstrange thing going on.\n\n>      ++\t\tcase \"${meld_use_auto_merge_option,,*}\" in\n\nDON'T. \n\nThe ${parameter,,pattern} expansion is one of the non-portable\nbash-isms we do not use in our codebase.  Use of it won't fix the\ncorrectness problem coming from not using --bool anyway, because ...\n\n>      ++\t\ttrue|yes|on|1)\n\n... any numeric value that is not 0 is taken as true.  Writing 1\nhere does not help.\n\n\n"},{"id":"401015","messageId":"20200703155812.GA4087@danh.dev","threadId":"53430","inReplyTo":"xmqqv9j5bc4o.fsf@gitster.c.googlers.com","subject":"Re: [PATCH v6] Support auto-merge for meld to follow the vim-diff behavior","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-07-03T15:58:12Z","receivedAt":"2020-07-03T15:58:17Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-07-02 18:50:15-0700, Junio C Hamano <gitster@pobox.com> wrote:\n> So, if we do not know yet, then...\n> \n> >  \tthen\n> > +\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n> > +\t\tcase \"$meld_use_auto_merge_option\" in\n> > +\t\t[Tt]rue|[Yy]es|[Oo]n|1)\n> > +\t\t\tmeld_use_auto_merge_option=true\n> \n> This is sloppy.  TRUE is also a valid way to spell 'yes'.\n> \n>     if o=$(git config --bool 2>/dev/null mergetool.meld.useautomerge)\n>     then\n>     \tmeld_use_auto_merge_option=$o\n>     elif test auto = \"$(git config mergetool.meld.useautomerge)\"\n>     then\n> \t... auto detect ...\n>     else\n> \tmeld_use_auto_merge_option=false\n>     fi\n\nSomething like this should work if we don't write anything to stderr,\nexcept the complain from git-config:\n\n> fatal: bad numeric config value 'auto' for 'mergetool.meld.useautomerge': invalid unit\n\n\tif o=$(git config --bool mergetool.meld.useautomerge 2>&1)\n\tthen\n\t\tmeld_use_auto_merge_option=$o\n\telse\n\t\tcase \"$o\" in\n\t\t*\"'auto'\"*) ... auto detect ... ;;\n\t\tesac\n\tfi\n\nThis code block is likely broken if git-config is chatty (trace).\nI don't know if we have a reliable ways to tell Git to not chatty,\nthough.\n\n\n-- \nDanh\n"},{"id":"401017","messageId":"pull.781.v8.git.git.1593825400699.gitgitgadget@gmail.com","threadId":"53430","inReplyTo":"pull.781.v7.git.git.1593746805771.gitgitgadget@gmail.com","subject":"[PATCH v8] Support auto-merge for meld to follow the vim-diff behavior","fromName":"sunlin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-07-04T01:16:40Z","receivedAt":"2020-07-04T01:16:46Z","isPatch":true,"sender":{"key":"name:sunlin","avatar":null},"body":"From: Lin Sun <lin.sun@zoom.us>\n\nMake the mergetool used with \"meld\" backend behave similarly to \"vimdiff\" by\ntelling it to auto-merge non-conflicting parts and highlight the conflicting\nparts when `mergetool.meld.useAutoMerge` is configured with `true`, or `auto`\nfor detecting the `--auto-merge` option automatically.\n\nHelped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\nHelped-by: Junio C Hamano <gitster@pobox.com>\nHelped-by: David Aguilar <davvid@gmail.com>\nSigned-off-by: Lin Sun <lin.sun@zoom.us>\n---\n    Enable auto-merge for meld to follow the vimdiff beharior\n    \n    Hi, the mergetool \"meld\" does NOT merge the no-conflict changes, while\n    the mergetool \"vimdiff\" will merge the no-conflict changes and highlight\n    the conflict parts. This patch will make the mergetool \"meld\" similar to\n    \"vimdiff\", auto-merge the no-conflict changes, highlight conflict parts.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-781%2Fsunlin7%2Fmaster-v8\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-781/sunlin7/master-v8\nPull-Request: https://github.com/git/git/pull/781\n\nRange-diff vs v7:\n\n 1:  ec2b49b9b8 ! 1:  f28a32c66e Support auto-merge for meld to follow the vim-diff behavior\n     @@ Metadata\n       ## Commit message ##\n          Support auto-merge for meld to follow the vim-diff behavior\n      \n     -    Make the mergetool used with \"meld\" backend behave similarly to\n     -    \"vimdiff\" by telling it to auto-merge non-conflicting parts and\n     -    highlight the conflicting parts when `mergetool.meld.useAutoMerge` is\n     -    configured with `true`, or `auto` for detecting the `--auto-merge`\n     -    option automatically.\n     +    Make the mergetool used with \"meld\" backend behave similarly to \"vimdiff\" by\n     +    telling it to auto-merge non-conflicting parts and highlight the conflicting\n     +    parts when `mergetool.meld.useAutoMerge` is configured with `true`, or `auto`\n     +    for detecting the `--auto-merge` option automatically.\n      \n          Helped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\n          Helped-by: Junio C Hamano <gitster@pobox.com>\n     @@ Documentation/config/mergetool.txt: mergetool.meld.hasOutput::\n       \tand `false` avoids using `--output`.\n       \n      +mergetool.meld.useAutoMerge::\n     -+\tWhen the `--auto-merge` is given, meld will merges all non-conflicting\n     -+\tpart automatically, highlight the conflicting part and waiting for user\n     -+\tdecision.  Setting `mergetool.meld.useAutoMerge` to `true` tells Git to\n     -+\tunconditionally use the `--auto-merge` option with `meld`.  Setting this\n     -+\tvalue to `auto` makes git detect whether `--auto-merge` is supported and\n     -+\twill only use `--auto-merge` when available.  A value of `false` avoids\n     -+\tusing `--auto-merge` altogether, and is the default value.\n     ++\tWhen the `--auto-merge` is given, meld will merge all non-conflicting\n     ++\tparts automatically, highlight the conflicting parts and waiting for\n     ++\tuser decision.  Setting `mergetool.meld.useAutoMerge` to `true` tells\n     ++\tGit to unconditionally use the `--auto-merge` option with `meld`.\n     ++\tSetting this value to `auto` makes git detect whether `--auto-merge`\n     ++\tis supported and will only use `--auto-merge` when available.  A\n     ++\tvalue of `false` avoids using `--auto-merge` altogether, and is the\n     ++\tdefault value.\n      +\n       mergetool.keepBackup::\n       \tAfter performing a merge, the original file with conflict markers\n     @@ mergetools/meld: diff_cmd () {\n      -\tmeld_path=\"${meld_path:-meld}\"\n      +# Get meld help message\n      +init_meld_help_msg () {\n     -+\tif test -z \"${meld_help_msg}\"\n     ++\tif test -z \"$meld_help_msg\"\n      +\tthen\n      +\t\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n      +\t\tmeld_help_msg=$($meld_path --help 2>&1)\n     @@ mergetools/meld: diff_cmd () {\n      +# Check the features and set flags\n      +check_meld_for_features () {\n      +\t# Check whether we should use 'meld --output <file>'\n     -+\tif test -z \"${meld_has_output_option}\"\n     ++\tif test -z \"$meld_has_output_option\"\n       \tthen\n      -\t\t: use configured value\n      -\telif \"$meld_path\" --help 2>&1 |\n     @@ mergetools/meld: diff_cmd () {\n      +\t\tesac\n      +\tfi\n      +\t# Check whether we should use 'meld --auto-merge ...'\n     -+\tif test -z \"${meld_use_auto_merge_option}\"\n     ++\tif test -z \"$meld_use_auto_merge_option\"\n       \tthen\n      -\t\t: old ones mention --output and new ones just say OPTION...\n      -\t\tmeld_has_output_option=true\n      -\telse\n      -\t\tmeld_has_output_option=false\n      +\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n     -+\t\tcase \"${meld_use_auto_merge_option,,*}\" in\n     -+\t\ttrue|yes|on|1)\n     -+\t\t\tmeld_use_auto_merge_option=true\n     -+\t\t\t;;\n     -+\t\tauto)\n     -+\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n     -+\t\t\tinit_meld_help_msg\n     ++\t\tif test -z \"$meld_use_auto_merge_option\"\n     ++\t\tthen\n     ++\t\t\tmeld_use_auto_merge_option=false\n     ++\t\telse\n     ++\t\t\tbool_value=$(git config --bool mergetool.meld.useAutoMerge 2>/dev/null)\n     ++\t\t\tif test -n \"$bool_value\"\n     ++\t\t\tthen\n     ++\t\t\t\tmeld_use_auto_merge_option=\"$bool_value\"\n     ++\t\t\telif test \"$meld_use_auto_merge_option\" = \"auto\" \\\n     ++\t\t\t\t|| test \"$meld_use_auto_merge_option\" = \"Auto\"\n     ++\t\t\tthen\n     ++\t\t\t\t# testing the \"--auto-merge\" option only if config is \"[Aa]uto\"\n     ++\t\t\t\tinit_meld_help_msg\n      +\n     -+\t\t\tcase \"$meld_help_msg\" in\n     -+\t\t\t*\"--auto-merge\"*)\n     -+\t\t\t\tmeld_use_auto_merge_option=true\n     -+\t\t\t\t;;\n     -+\t\t\t*)\n     ++\t\t\t\tcase \"$meld_help_msg\" in\n     ++\t\t\t\t*\"--auto-merge\"*)\n     ++\t\t\t\t\tmeld_use_auto_merge_option=true\n     ++\t\t\t\t\t;;\n     ++\t\t\t\t*)\n     ++\t\t\t\t\tmeld_use_auto_merge_option=false\n     ++\t\t\t\t\t;;\n     ++\t\t\t\tesac\n     ++\t\t\telse\n      +\t\t\t\tmeld_use_auto_merge_option=false\n     -+\t\t\t\t;;\n     -+\t\t\tesac\n     -+\t\t\t;;\n     -+\t\t*)\n     -+\t\t\tmeld_use_auto_merge_option=false\n     -+\t\t\t;;\n     -+\t\tesac\n     ++\t\t\tfi\n     ++\t\tfi\n       \tfi\n       }\n\n\n Documentation/config/mergetool.txt | 10 ++++\n mergetools/meld                    | 85 ++++++++++++++++++++++++------\n 2 files changed, 79 insertions(+), 16 deletions(-)\n\ndiff --git a/Documentation/config/mergetool.txt b/Documentation/config/mergetool.txt\nindex 09ed31dbfa..031c78aa95 100644\n--- a/Documentation/config/mergetool.txt\n+++ b/Documentation/config/mergetool.txt\n@@ -30,6 +30,16 @@ mergetool.meld.hasOutput::\n \tto `true` tells Git to unconditionally use the `--output` option,\n \tand `false` avoids using `--output`.\n \n+mergetool.meld.useAutoMerge::\n+\tWhen the `--auto-merge` is given, meld will merge all non-conflicting\n+\tparts automatically, highlight the conflicting parts and waiting for\n+\tuser decision.  Setting `mergetool.meld.useAutoMerge` to `true` tells\n+\tGit to unconditionally use the `--auto-merge` option with `meld`.\n+\tSetting this value to `auto` makes git detect whether `--auto-merge`\n+\tis supported and will only use `--auto-merge` when available.  A\n+\tvalue of `false` avoids using `--auto-merge` altogether, and is the\n+\tdefault value.\n+\n mergetool.keepBackup::\n \tAfter performing a merge, the original file with conflict markers\n \tcan be saved as a file with a `.orig` extension.  If this variable\ndiff --git a/mergetools/meld b/mergetools/meld\nindex 7a08470f88..7b9d917f7a 100644\n--- a/mergetools/meld\n+++ b/mergetools/meld\n@@ -3,34 +3,87 @@ diff_cmd () {\n }\n \n merge_cmd () {\n-\tif test -z \"${meld_has_output_option:+set}\"\n+\tcheck_meld_for_features\n+\n+\toption_auto_merge=\n+\tif test \"$meld_use_auto_merge_option\" = true\n \tthen\n-\t\tcheck_meld_for_output_version\n+\t\toption_auto_merge=\"--auto-merge\"\n \tfi\n \n \tif test \"$meld_has_output_option\" = true\n \tthen\n-\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n+\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \telse\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \tfi\n }\n \n-# Check whether we should use 'meld --output <file>'\n-check_meld_for_output_version () {\n-\tmeld_path=\"$(git config mergetool.meld.path)\"\n-\tmeld_path=\"${meld_path:-meld}\"\n+# Get meld help message\n+init_meld_help_msg () {\n+\tif test -z \"$meld_help_msg\"\n+\tthen\n+\t\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n+\t\tmeld_help_msg=$($meld_path --help 2>&1)\n+\tfi\n+}\n \n-\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+# Check the features and set flags\n+check_meld_for_features () {\n+\t# Check whether we should use 'meld --output <file>'\n+\tif test -z \"$meld_has_output_option\"\n \tthen\n-\t\t: use configured value\n-\telif \"$meld_path\" --help 2>&1 |\n-\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n+\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+\t\tcase \"$meld_has_output_option\" in\n+\t\ttrue|false)\n+\t\t\t: use configured value\n+\t\t\t;;\n+\t\t*)\n+\t\t\t: empty or invalid configured value, detecting \"--output\" automatically\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--output=\"* | *'[OPTION...]'*)\n+\t\t\t\t# All version that has [OPTION...] supports --output\n+\t\t\t\tmeld_has_output_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_has_output_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\tesac\n+\tfi\n+\t# Check whether we should use 'meld --auto-merge ...'\n+\tif test -z \"$meld_use_auto_merge_option\"\n \tthen\n-\t\t: old ones mention --output and new ones just say OPTION...\n-\t\tmeld_has_output_option=true\n-\telse\n-\t\tmeld_has_output_option=false\n+\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n+\t\tif test -z \"$meld_use_auto_merge_option\"\n+\t\tthen\n+\t\t\tmeld_use_auto_merge_option=false\n+\t\telse\n+\t\t\tbool_value=$(git config --bool mergetool.meld.useAutoMerge 2>/dev/null)\n+\t\t\tif test -n \"$bool_value\"\n+\t\t\tthen\n+\t\t\t\tmeld_use_auto_merge_option=\"$bool_value\"\n+\t\t\telif test \"$meld_use_auto_merge_option\" = \"auto\" \\\n+\t\t\t\t|| test \"$meld_use_auto_merge_option\" = \"Auto\"\n+\t\t\tthen\n+\t\t\t\t# testing the \"--auto-merge\" option only if config is \"[Aa]uto\"\n+\t\t\t\tinit_meld_help_msg\n+\n+\t\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t\t*\"--auto-merge\"*)\n+\t\t\t\t\tmeld_use_auto_merge_option=true\n+\t\t\t\t\t;;\n+\t\t\t\t*)\n+\t\t\t\t\tmeld_use_auto_merge_option=false\n+\t\t\t\t\t;;\n+\t\t\t\tesac\n+\t\t\telse\n+\t\t\t\tmeld_use_auto_merge_option=false\n+\t\t\tfi\n+\t\tfi\n \tfi\n }\n\nbase-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n-- \ngitgitgadget\n"},{"id":"401018","messageId":"2920401d651a1$1ac3ea80$504bbf80$@zoom.us","threadId":"53430","inReplyTo":"xmqqo8oxb3rv.fsf@gitster.c.googlers.com","subject":"RE: [PATCH v7] Support auto-merge for meld to follow the vim-diff behavior","fromName":"","fromEmail":"lin.sun@zoom.us","sentAt":"2020-07-04T01:18:59Z","receivedAt":"2020-07-04T01:19:08Z","isPatch":true,"sender":{"key":"lin.sun@zoom.us","avatar":null},"body":"Hi Junio, Doah,\n\nTo follow your comments, the new [PATCH v8] is uploaded, try to reduce calling `git config --bool`.\nPlease review again. Thank you.\nhttps://lore.kernel.org/git/pull.781.v8.git.git.1593825400699.gitgitgadget@gmail.com/\n\nB.R.\nLin\n\n"},{"id":"401034","messageId":"pull.781.v9.git.git.1594002423685.gitgitgadget@gmail.com","threadId":"53430","inReplyTo":"pull.781.v8.git.git.1593825400699.gitgitgadget@gmail.com","subject":"[PATCH v9] Support auto-merge for meld to follow the vim-diff behavior","fromName":"sunlin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-07-06T02:27:03Z","receivedAt":"2020-07-06T02:27:08Z","isPatch":true,"sender":{"key":"name:sunlin","avatar":null},"body":"From: Lin Sun <lin.sun@zoom.us>\n\nMake the mergetool used with \"meld\" backend behave similarly to \"vimdiff\" by\ntelling it to auto-merge non-conflicting parts and highlight the conflicting\nparts when `mergetool.meld.useAutoMerge` is configured with `true`, or `auto`\nfor detecting the `--auto-merge` option automatically.\n\nHelped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\nHelped-by: Junio C Hamano <gitster@pobox.com>\nHelped-by: David Aguilar <davvid@gmail.com>\nSigned-off-by: Lin Sun <lin.sun@zoom.us>\n---\n    Enable auto-merge for meld to follow the vimdiff beharior\n    \n    Hi, the mergetool \"meld\" does NOT merge the no-conflict changes, while\n    the mergetool \"vimdiff\" will merge the no-conflict changes and highlight\n    the conflict parts. This patch will make the mergetool \"meld\" similar to\n    \"vimdiff\", auto-merge the no-conflict changes, highlight conflict parts.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-781%2Fsunlin7%2Fmaster-v9\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-781/sunlin7/master-v9\nPull-Request: https://github.com/git/git/pull/781\n\nRange-diff vs v8:\n\n 1:  f28a32c66e ! 1:  95586fb2c2 Support auto-merge for meld to follow the vim-diff behavior\n     @@ mergetools/meld: diff_cmd () {\n      -\telse\n      -\t\tmeld_has_output_option=false\n      +\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n     -+\t\tif test -z \"$meld_use_auto_merge_option\"\n     -+\t\tthen\n     ++\t\tcase \"$meld_use_auto_merge_option\" in\n     ++\t\t\"\")\n      +\t\t\tmeld_use_auto_merge_option=false\n     -+\t\telse\n     ++\t\t\t;;\n     ++\t\t[Aa]uto)\n     ++\t\t\t# testing the \"--auto-merge\" option only if config is \"[Aa]uto\"\n     ++\t\t\tinit_meld_help_msg\n     ++\n     ++\t\t\tcase \"$meld_help_msg\" in\n     ++\t\t\t*\"--auto-merge\"*)\n     ++\t\t\t\tmeld_use_auto_merge_option=true\n     ++\t\t\t\t;;\n     ++\t\t\t*)\n     ++\t\t\t\tmeld_use_auto_merge_option=false\n     ++\t\t\t\t;;\n     ++\t\t\tesac\n     ++\t\t\t;;\n     ++\t\t*)\n      +\t\t\tbool_value=$(git config --bool mergetool.meld.useAutoMerge 2>/dev/null)\n      +\t\t\tif test -n \"$bool_value\"\n      +\t\t\tthen\n      +\t\t\t\tmeld_use_auto_merge_option=\"$bool_value\"\n     -+\t\t\telif test \"$meld_use_auto_merge_option\" = \"auto\" \\\n     -+\t\t\t\t|| test \"$meld_use_auto_merge_option\" = \"Auto\"\n     -+\t\t\tthen\n     -+\t\t\t\t# testing the \"--auto-merge\" option only if config is \"[Aa]uto\"\n     -+\t\t\t\tinit_meld_help_msg\n     -+\n     -+\t\t\t\tcase \"$meld_help_msg\" in\n     -+\t\t\t\t*\"--auto-merge\"*)\n     -+\t\t\t\t\tmeld_use_auto_merge_option=true\n     -+\t\t\t\t\t;;\n     -+\t\t\t\t*)\n     -+\t\t\t\t\tmeld_use_auto_merge_option=false\n     -+\t\t\t\t\t;;\n     -+\t\t\t\tesac\n      +\t\t\telse\n      +\t\t\t\tmeld_use_auto_merge_option=false\n      +\t\t\tfi\n     -+\t\tfi\n     ++\t\t\t;;\n     ++\t\tesac\n       \tfi\n       }\n\n\n Documentation/config/mergetool.txt | 10 ++++\n mergetools/meld                    | 86 ++++++++++++++++++++++++------\n 2 files changed, 80 insertions(+), 16 deletions(-)\n\ndiff --git a/Documentation/config/mergetool.txt b/Documentation/config/mergetool.txt\nindex 09ed31dbfa..031c78aa95 100644\n--- a/Documentation/config/mergetool.txt\n+++ b/Documentation/config/mergetool.txt\n@@ -30,6 +30,16 @@ mergetool.meld.hasOutput::\n \tto `true` tells Git to unconditionally use the `--output` option,\n \tand `false` avoids using `--output`.\n \n+mergetool.meld.useAutoMerge::\n+\tWhen the `--auto-merge` is given, meld will merge all non-conflicting\n+\tparts automatically, highlight the conflicting parts and waiting for\n+\tuser decision.  Setting `mergetool.meld.useAutoMerge` to `true` tells\n+\tGit to unconditionally use the `--auto-merge` option with `meld`.\n+\tSetting this value to `auto` makes git detect whether `--auto-merge`\n+\tis supported and will only use `--auto-merge` when available.  A\n+\tvalue of `false` avoids using `--auto-merge` altogether, and is the\n+\tdefault value.\n+\n mergetool.keepBackup::\n \tAfter performing a merge, the original file with conflict markers\n \tcan be saved as a file with a `.orig` extension.  If this variable\ndiff --git a/mergetools/meld b/mergetools/meld\nindex 7a08470f88..ba6607a088 100644\n--- a/mergetools/meld\n+++ b/mergetools/meld\n@@ -3,34 +3,88 @@ diff_cmd () {\n }\n \n merge_cmd () {\n-\tif test -z \"${meld_has_output_option:+set}\"\n+\tcheck_meld_for_features\n+\n+\toption_auto_merge=\n+\tif test \"$meld_use_auto_merge_option\" = true\n \tthen\n-\t\tcheck_meld_for_output_version\n+\t\toption_auto_merge=\"--auto-merge\"\n \tfi\n \n \tif test \"$meld_has_output_option\" = true\n \tthen\n-\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n+\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \telse\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \tfi\n }\n \n-# Check whether we should use 'meld --output <file>'\n-check_meld_for_output_version () {\n-\tmeld_path=\"$(git config mergetool.meld.path)\"\n-\tmeld_path=\"${meld_path:-meld}\"\n+# Get meld help message\n+init_meld_help_msg () {\n+\tif test -z \"$meld_help_msg\"\n+\tthen\n+\t\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n+\t\tmeld_help_msg=$($meld_path --help 2>&1)\n+\tfi\n+}\n \n-\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+# Check the features and set flags\n+check_meld_for_features () {\n+\t# Check whether we should use 'meld --output <file>'\n+\tif test -z \"$meld_has_output_option\"\n \tthen\n-\t\t: use configured value\n-\telif \"$meld_path\" --help 2>&1 |\n-\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n+\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+\t\tcase \"$meld_has_output_option\" in\n+\t\ttrue|false)\n+\t\t\t: use configured value\n+\t\t\t;;\n+\t\t*)\n+\t\t\t: empty or invalid configured value, detecting \"--output\" automatically\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--output=\"* | *'[OPTION...]'*)\n+\t\t\t\t# All version that has [OPTION...] supports --output\n+\t\t\t\tmeld_has_output_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_has_output_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\tesac\n+\tfi\n+\t# Check whether we should use 'meld --auto-merge ...'\n+\tif test -z \"$meld_use_auto_merge_option\"\n \tthen\n-\t\t: old ones mention --output and new ones just say OPTION...\n-\t\tmeld_has_output_option=true\n-\telse\n-\t\tmeld_has_output_option=false\n+\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n+\t\tcase \"$meld_use_auto_merge_option\" in\n+\t\t\"\")\n+\t\t\tmeld_use_auto_merge_option=false\n+\t\t\t;;\n+\t\t[Aa]uto)\n+\t\t\t# testing the \"--auto-merge\" option only if config is \"[Aa]uto\"\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--auto-merge\"*)\n+\t\t\t\tmeld_use_auto_merge_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_use_auto_merge_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\t*)\n+\t\t\tbool_value=$(git config --bool mergetool.meld.useAutoMerge 2>/dev/null)\n+\t\t\tif test -n \"$bool_value\"\n+\t\t\tthen\n+\t\t\t\tmeld_use_auto_merge_option=\"$bool_value\"\n+\t\t\telse\n+\t\t\t\tmeld_use_auto_merge_option=false\n+\t\t\tfi\n+\t\t\t;;\n+\t\tesac\n \tfi\n }\n\nbase-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n-- \ngitgitgadget\n"},{"id":"401035","messageId":"2c85c01d6533e$33d4cc30$9b7e6490$@zoom.us","threadId":"53430","inReplyTo":"2920401d651a1$1ac3ea80$504bbf80$@zoom.us","subject":"RE: [PATCH v7] Support auto-merge for meld to follow the vim-diff behavior","fromName":"","fromEmail":"lin.sun@zoom.us","sentAt":"2020-07-06T02:36:04Z","receivedAt":"2020-07-06T02:41:12Z","isPatch":true,"sender":{"key":"lin.sun@zoom.us","avatar":null},"body":"Hi Junio, Doah,\n\n>To follow your comments, the new [PATCH v8] is uploaded, try to reduce calling `git config --bool`.\n>Please review again. Thank you.\n>https://lore.kernel.org/git/pull.781.v8.git.git.1593825400699.gitgitgadget@gmail.com/\n\nPlease review the [PATCH v9] instead, it will calling the `git config --bool ...` until last moment.\nhttps://lore.kernel.org/git/pull.781.v9.git.git.1594002423685.gitgitgadget@gmail.com/\n\nB.R.\nLin\n\n\n"},{"id":"401036","messageId":"xmqqzh8d9n74.fsf@gitster.c.googlers.com","threadId":"53430","inReplyTo":"20200703155812.GA4087@danh.dev","subject":"Re: [PATCH v6] Support auto-merge for meld to follow the vim-diff behavior","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-07-06T06:23:11Z","receivedAt":"2020-07-06T06:23:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Đoàn Trần Công Danh  <congdanhqx@gmail.com> writes:\n\n>>     if o=$(git config --bool 2>/dev/null mergetool.meld.useautomerge)\n>>     then\n>>     \tmeld_use_auto_merge_option=$o\n>>     elif test auto = \"$(git config mergetool.meld.useautomerge)\"\n>>     then\n>> \t... auto detect ...\n>>     else\n>> \tmeld_use_auto_merge_option=false\n>>     fi\n>\n> Something like this should work if we don't write anything to stderr,\n> except the complain from git-config:\n\nI did say \"Maybe somebody else has a clever idea to reduce the two\ncalls into one without breaking correctness\" but the stress is on\nthe \"without breaking correctness\" part, not on \"clever\" part.  Two\n\"git config\" call may be more expensive than one call, but at least\nthe resulting code is readable.\n\nIf we really wanted to, I think the way to go would actually be to\nteach \"git config\" new options that allows us scripters to express\nwhat we can already say internally like \"maybe bool\", \"bool or int\",\netc.  IOW, \"git config --bool-or-string\" that does something like\n\nint git_config_bool_or_str(const char **dest,\n\t\t\t   const char *name, const char *value);\n{\n\tint v = git_parse_maybe_bool_text(value);\n\tif (0 <= v)\n        \t*dest = v ? \"true\" : \"false\";\n\telse                \n        \t*dest = value;\n\treturn 0;\n}\n\nmay help normalizing various ways to spell boolean plus non-boolean\nstrings into canonical form, so that you can say\n\n\tif o=$(git config --bool-or-string mergetool.meld.useautomerge)\"\n\tthen\n\t\tcase \"$o\" in\n\t\ttrue | false)\n\t\t        meld_use_auto_merge_option=$o # as specified\n\t\t\t;;\n\t\tauto)\n\t\t\t... auto detect ...\n\t\t\t;;\n\t\tesac\n\telse\n\t\tmeld_use_auto_merge_option=false\n\tfi\n\t\nBut I think two calls to config is good enough and it certainly is\nnot worth making the script ugly with hackeries and/or manually\nenumerating all the possible shapes of trues and falses.\n\nThanks.\n"},{"id":"401056","messageId":"xmqqzh8c8eda.fsf@gitster.c.googlers.com","threadId":"53430","inReplyTo":"pull.781.v9.git.git.1594002423685.gitgitgadget@gmail.com","subject":"Re: [PATCH v9] Support auto-merge for meld to follow the vim-diff behavior","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-07-06T22:31:29Z","receivedAt":"2020-07-06T22:31:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"sunlin via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Lin Sun <lin.sun@zoom.us>\n>\n> Make the mergetool used with \"meld\" backend behave similarly to \"vimdiff\" by\n> telling it to auto-merge non-conflicting parts and highlight the conflicting\n> parts when `mergetool.meld.useAutoMerge` is configured with `true`, or `auto`\n> for detecting the `--auto-merge` option automatically.\n\nThis reads well.\n\n> +mergetool.meld.useAutoMerge::\n> +\tWhen the `--auto-merge` is given, meld will merge all non-conflicting\n> +\tparts automatically, highlight the conflicting parts and waiting for\n\ns/waiting/wait/, I presume, i.e. \"merge\", \"highlight\" and \"wait\" all \nshare the \"meld will\" that starts the sentence.\n\n> +\tuser decision.  Setting `mergetool.meld.useAutoMerge` to `true` tells\n> +\tGit to unconditionally use the `--auto-merge` option with `meld`.\n> +\tSetting this value to `auto` makes git detect whether `--auto-merge`\n> +\tis supported and will only use `--auto-merge` when available.  A\n> +\tvalue of `false` avoids using `--auto-merge` altogether, and is the\n> +\tdefault value.\n\nOther than that, this reads well, too.\n\n> diff --git a/mergetools/meld b/mergetools/meld\n> index 7a08470f88..ba6607a088 100644\n> --- a/mergetools/meld\n> +++ b/mergetools/meld\n> @@ -3,34 +3,88 @@ diff_cmd () {\n>  }\n>  \n>  merge_cmd () {\n> +\tcheck_meld_for_features\n> +\n> +\toption_auto_merge=\n> +\tif test \"$meld_use_auto_merge_option\" = true\n>  \tthen\n> +\t\toption_auto_merge=\"--auto-merge\"\n>  \tfi\n>  \n>  \tif test \"$meld_has_output_option\" = true\n>  \tthen\n> +\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n>  \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n>  \telse\n> +\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n>  \tfi\n>  }\n\nOK.\n\n> +# Get meld help message\n> +init_meld_help_msg () {\n> +\tif test -z \"$meld_help_msg\"\n> +\tthen\n> +\t\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n> +\t\tmeld_help_msg=$($meld_path --help 2>&1)\n> +\tfi\n> +}\n\nOK.\n\n> +# Check the features and set flags\n> +check_meld_for_features () {\n> +\t# Check whether we should use 'meld --output <file>'\n> +\tif test -z \"$meld_has_output_option\"\n>  \tthen\n> +\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n> +\t\tcase \"$meld_has_output_option\" in\n> +\t\ttrue|false)\n> +\t\t\t: use configured value\n> +\t\t\t;;\n\nI think the assignment before \"case\" would have yielded a non-zero\nexist status, so that would be another way to tell if we got a\nproper boolean value, but this is also good.\n\n> +\t\t*)\n> +\t\t\t: empty or invalid configured value, detecting \"--output\" automatically\n> +\t\t\tinit_meld_help_msg\n> +\n> +\t\t\tcase \"$meld_help_msg\" in\n> +\t\t\t*\"--output=\"* | *'[OPTION...]'*)\n> +\t\t\t\t# All version that has [OPTION...] supports --output\n> +\t\t\t\tmeld_has_output_option=true\n> +\t\t\t\t;;\n> +\t\t\t*)\n> +\t\t\t\tmeld_has_output_option=false\n> +\t\t\t\t;;\n> +\t\t\tesac\n> +\t\t\t;;\n\nOK.\n\n> +\t\tesac\n> +\tfi\n> +\t# Check whether we should use 'meld --auto-merge ...'\n> +\tif test -z \"$meld_use_auto_merge_option\"\n>  \tthen\n> +\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n> +\t\tcase \"$meld_use_auto_merge_option\" in\n> +\t\t\"\")\n> +\t\t\tmeld_use_auto_merge_option=false\n\nThis is wrong, isn't it?  I have\n\n\t[rerere] enabled\n\nin my .git/config and I'd certainly get an empty string if you ask\nabout it in a non-bool context:\n\n    $ o=$(git config --bool rerere.enabled); echo $o\n    true\n    $ o=$(git config rerere.enabled); echo $o\n\n    $    \n\nIn short, I think you can just drop this test for an empty string here.\n\n> +\t\t\t;;\n> +\t\t[Aa]uto)\n\nDoes any other configuration variable that takes \"auto\" take \"Auto\",\n\"AUTO\", etc. as syonyms?  It's not like we said \"you must create a\nfile whose name is auto to trigger this feature\" and some people\nlive on a case insensitive filesystem that may make it impossible\nfor them to do so, so I do not see much point in doing this.\n\n> +\t\t\t# testing the \"--auto-merge\" option only if config is \"[Aa]uto\"\n> +\t\t\tinit_meld_help_msg\n> +\n> +\t\t\tcase \"$meld_help_msg\" in\n> +\t\t\t*\"--auto-merge\"*)\n> +\t\t\t\tmeld_use_auto_merge_option=true\n> +\t\t\t\t;;\n> +\t\t\t*)\n> +\t\t\t\tmeld_use_auto_merge_option=false\n> +\t\t\t\t;;\n> +\t\t\tesac\n\nI didn't notice this until now, but for \"--auto-merge\", the \"if your\nmeld is new enough, the option name may not appear and you would\nonly see [OPTION...]\" rule we had for the \"--output\" does not apply?\n\nI am not a meld user, and \"yes, my code is correct\" is a perfectly\ngood answer (in other word, the above question is NOT a rhetorical\none that points out an error in the code being reviewed).\n\n> +\t\t\t;;\n> +\t\t*)\n> +\t\t\tbool_value=$(git config --bool mergetool.meld.useAutoMerge 2>/dev/null)\n> +\t\t\tif test -n \"$bool_value\"\n> +\t\t\tthen\n> +\t\t\t\tmeld_use_auto_merge_option=\"$bool_value\"\n> +\t\t\telse\n> +\t\t\t\tmeld_use_auto_merge_option=false\n> +\t\t\tfi\n> +\t\t\t;;\n\nPerhaps the whole thing is easier to read if it is structured more\nlike so:\n\n\tvarname=mergetool.meld.useAutoMerge\n\tif meld_use_auto_merge_option=$(git config --bool \"$varname\" 2>/dev/null)\n\tthen\n        \t: happy\n\telse\n                # not a boolean.  Is it 'auto'?\n\t\tval=$(git config \"$varname\")\n                case \"$val\" in\n                auto)\n                        ;;\n                *)\n                        die \"unrecognized value '$val' for $varname\"\n                        ;;;\n                esac\n                ... here we auto detect ...\n\tfi\n\nThanks.\n"},{"id":"401076","messageId":"pull.781.v10.git.git.1594102679750.gitgitgadget@gmail.com","threadId":"53430","inReplyTo":"pull.781.v9.git.git.1594002423685.gitgitgadget@gmail.com","subject":"[PATCH v10] Support auto-merge for meld to follow the vim-diff behavior","fromName":"sunlin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-07-07T06:17:59Z","receivedAt":"2020-07-07T06:18:04Z","isPatch":true,"sender":{"key":"name:sunlin","avatar":null},"body":"From: Lin Sun <lin.sun@zoom.us>\n\nMake the mergetool used with \"meld\" backend behave similarly to \"vimdiff\" by\ntelling it to auto-merge non-conflicting parts and highlight the conflicting\nparts when `mergetool.meld.useAutoMerge` is configured with `true`, or `auto`\nfor detecting the `--auto-merge` option automatically.\n\nHelped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\nHelped-by: David Aguilar <davvid@gmail.com>\nSigned-off-by: Lin Sun <lin.sun@zoom.us>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n    Enable auto-merge for meld to follow the vimdiff beharior\n    \n    Hi, the mergetool \"meld\" does NOT merge the no-conflict changes, while\n    the mergetool \"vimdiff\" will merge the no-conflict changes and highlight\n    the conflict parts. This patch will make the mergetool \"meld\" similar to\n    \"vimdiff\", auto-merge the no-conflict changes, highlight conflict parts.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-781%2Fsunlin7%2Fmaster-v10\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-781/sunlin7/master-v10\nPull-Request: https://github.com/git/git/pull/781\n\nRange-diff vs v9:\n\n 1:  95586fb2c2 ! 1:  a4f1b8c2fa Support auto-merge for meld to follow the vim-diff behavior\n     @@ Commit message\n          for detecting the `--auto-merge` option automatically.\n      \n          Helped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\n     -    Helped-by: Junio C Hamano <gitster@pobox.com>\n          Helped-by: David Aguilar <davvid@gmail.com>\n          Signed-off-by: Lin Sun <lin.sun@zoom.us>\n     +    Signed-off-by: Junio C Hamano <gitster@pobox.com>\n      \n       ## Documentation/config/mergetool.txt ##\n      @@ Documentation/config/mergetool.txt: mergetool.meld.hasOutput::\n     @@ Documentation/config/mergetool.txt: mergetool.meld.hasOutput::\n       \n      +mergetool.meld.useAutoMerge::\n      +\tWhen the `--auto-merge` is given, meld will merge all non-conflicting\n     -+\tparts automatically, highlight the conflicting parts and waiting for\n     ++\tparts automatically, highlight the conflicting parts and wait for\n      +\tuser decision.  Setting `mergetool.meld.useAutoMerge` to `true` tells\n      +\tGit to unconditionally use the `--auto-merge` option with `meld`.\n      +\tSetting this value to `auto` makes git detect whether `--auto-merge`\n     @@ mergetools/meld: diff_cmd () {\n      +\t\t\"\")\n      +\t\t\tmeld_use_auto_merge_option=false\n      +\t\t\t;;\n     -+\t\t[Aa]uto)\n     -+\t\t\t# testing the \"--auto-merge\" option only if config is \"[Aa]uto\"\n     ++\t\t[Tt]ure|TRUE)\n     ++\t\t\tmeld_use_auto_merge_option=true\n     ++\t\t\t;;\n     ++\t\t[Ff]alse|FALSE)\n     ++\t\t\tmeld_use_auto_merge_option=false\n     ++\t\t\t;;\n     ++\t\t[Aa]uto|AUTO)\n     ++\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n      +\t\t\tinit_meld_help_msg\n      +\n      +\t\t\tcase \"$meld_help_msg\" in\n     @@ mergetools/meld: diff_cmd () {\n      +\t\t\tesac\n      +\t\t\t;;\n      +\t\t*)\n     ++\t\t\t# try detect boolean for 'on'||'yes'||numberic value\n      +\t\t\tbool_value=$(git config --bool mergetool.meld.useAutoMerge 2>/dev/null)\n      +\t\t\tif test -n \"$bool_value\"\n      +\t\t\tthen\n\n\n Documentation/config/mergetool.txt | 10 ++++\n mergetools/meld                    | 93 +++++++++++++++++++++++++-----\n 2 files changed, 87 insertions(+), 16 deletions(-)\n\ndiff --git a/Documentation/config/mergetool.txt b/Documentation/config/mergetool.txt\nindex 09ed31dbfa..16a27443a3 100644\n--- a/Documentation/config/mergetool.txt\n+++ b/Documentation/config/mergetool.txt\n@@ -30,6 +30,16 @@ mergetool.meld.hasOutput::\n \tto `true` tells Git to unconditionally use the `--output` option,\n \tand `false` avoids using `--output`.\n \n+mergetool.meld.useAutoMerge::\n+\tWhen the `--auto-merge` is given, meld will merge all non-conflicting\n+\tparts automatically, highlight the conflicting parts and wait for\n+\tuser decision.  Setting `mergetool.meld.useAutoMerge` to `true` tells\n+\tGit to unconditionally use the `--auto-merge` option with `meld`.\n+\tSetting this value to `auto` makes git detect whether `--auto-merge`\n+\tis supported and will only use `--auto-merge` when available.  A\n+\tvalue of `false` avoids using `--auto-merge` altogether, and is the\n+\tdefault value.\n+\n mergetool.keepBackup::\n \tAfter performing a merge, the original file with conflict markers\n \tcan be saved as a file with a `.orig` extension.  If this variable\ndiff --git a/mergetools/meld b/mergetools/meld\nindex 7a08470f88..0250c1554a 100644\n--- a/mergetools/meld\n+++ b/mergetools/meld\n@@ -3,34 +3,95 @@ diff_cmd () {\n }\n \n merge_cmd () {\n-\tif test -z \"${meld_has_output_option:+set}\"\n+\tcheck_meld_for_features\n+\n+\toption_auto_merge=\n+\tif test \"$meld_use_auto_merge_option\" = true\n \tthen\n-\t\tcheck_meld_for_output_version\n+\t\toption_auto_merge=\"--auto-merge\"\n \tfi\n \n \tif test \"$meld_has_output_option\" = true\n \tthen\n-\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n+\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \telse\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \tfi\n }\n \n-# Check whether we should use 'meld --output <file>'\n-check_meld_for_output_version () {\n-\tmeld_path=\"$(git config mergetool.meld.path)\"\n-\tmeld_path=\"${meld_path:-meld}\"\n+# Get meld help message\n+init_meld_help_msg () {\n+\tif test -z \"$meld_help_msg\"\n+\tthen\n+\t\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n+\t\tmeld_help_msg=$($meld_path --help 2>&1)\n+\tfi\n+}\n \n-\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+# Check the features and set flags\n+check_meld_for_features () {\n+\t# Check whether we should use 'meld --output <file>'\n+\tif test -z \"$meld_has_output_option\"\n \tthen\n-\t\t: use configured value\n-\telif \"$meld_path\" --help 2>&1 |\n-\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n+\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+\t\tcase \"$meld_has_output_option\" in\n+\t\ttrue|false)\n+\t\t\t: use configured value\n+\t\t\t;;\n+\t\t*)\n+\t\t\t: empty or invalid configured value, detecting \"--output\" automatically\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--output=\"* | *'[OPTION...]'*)\n+\t\t\t\t# All version that has [OPTION...] supports --output\n+\t\t\t\tmeld_has_output_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_has_output_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\tesac\n+\tfi\n+\t# Check whether we should use 'meld --auto-merge ...'\n+\tif test -z \"$meld_use_auto_merge_option\"\n \tthen\n-\t\t: old ones mention --output and new ones just say OPTION...\n-\t\tmeld_has_output_option=true\n-\telse\n-\t\tmeld_has_output_option=false\n+\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n+\t\tcase \"$meld_use_auto_merge_option\" in\n+\t\t\"\")\n+\t\t\tmeld_use_auto_merge_option=false\n+\t\t\t;;\n+\t\t[Tt]ure|TRUE)\n+\t\t\tmeld_use_auto_merge_option=true\n+\t\t\t;;\n+\t\t[Ff]alse|FALSE)\n+\t\t\tmeld_use_auto_merge_option=false\n+\t\t\t;;\n+\t\t[Aa]uto|AUTO)\n+\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--auto-merge\"*)\n+\t\t\t\tmeld_use_auto_merge_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_use_auto_merge_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\t*)\n+\t\t\t# try detect boolean for 'on'||'yes'||numberic value\n+\t\t\tbool_value=$(git config --bool mergetool.meld.useAutoMerge 2>/dev/null)\n+\t\t\tif test -n \"$bool_value\"\n+\t\t\tthen\n+\t\t\t\tmeld_use_auto_merge_option=\"$bool_value\"\n+\t\t\telse\n+\t\t\t\tmeld_use_auto_merge_option=false\n+\t\t\tfi\n+\t\t\t;;\n+\t\tesac\n \tfi\n }\n\nbase-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n-- \ngitgitgadget\n"},{"id":"401079","messageId":"xmqqd0577sei.fsf@gitster.c.googlers.com","threadId":"53430","inReplyTo":"pull.781.v10.git.git.1594102679750.gitgitgadget@gmail.com","subject":"Re: [PATCH v10] Support auto-merge for meld to follow the vim-diff behavior","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-07-07T06:25:57Z","receivedAt":"2020-07-07T06:26:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"sunlin via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> +\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n> +\t\tcase \"$meld_use_auto_merge_option\" in\n> +\t\t\"\")\n> +\t\t\tmeld_use_auto_merge_option=false\n> +\t\t\t;;\n\nI somehow thought that I already pointed out that this is wrong,\ndidn't I?  You cannot tell between a \"[section] var\" (which is\n\"true\") and not having any \"[section] var = val\" (which I think you\nare trying to treat as \"not configured---do not use\") from the\noutput of \"git config section.var\".\n\nPerhaps our mails crossed?\n\n> +\t\t[Tt]ure|TRUE)\n> +\t\t\tmeld_use_auto_merge_option=true\n> +\t\t\t;;\n> +\t\t[Ff]alse|FALSE)\n> +\t\t\tmeld_use_auto_merge_option=false\n> +\t\t\t;;\n\nThese are probably premature optimizations.\n\n> +\t\t[Aa]uto|AUTO)\n\nSigh.  I somehow thought that I already said we shouldn't do this\n\"aCCEpt AnY CaSES\" unless all other variables that take 'auto' take\nit case insensitively.\n\n> +\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n> +\t\t\tinit_meld_help_msg\n> +\n> +\t\t\tcase \"$meld_help_msg\" in\n> +\t\t\t*\"--auto-merge\"*)\n> +\t\t\t\tmeld_use_auto_merge_option=true\n> +\t\t\t\t;;\n> +\t\t\t*)\n> +\t\t\t\tmeld_use_auto_merge_option=false\n> +\t\t\t\t;;\n> +\t\t\tesac\n> +\t\t\t;;\n> +\t\t*)\n> +\t\t\t# try detect boolean for 'on'||'yes'||numberic value\n> +\t\t\tbool_value=$(git config --bool mergetool.meld.useAutoMerge 2>/dev/null)\n> +\t\t\tif test -n \"$bool_value\"\n> +\t\t\tthen\n> +\t\t\t\tmeld_use_auto_merge_option=\"$bool_value\"\n> +\t\t\telse\n> +\t\t\t\tmeld_use_auto_merge_option=false\n\nI think this case (i.e. set to a non-bool value, and we do not\nrecognise because it is not 'auto') should be flagged as an error,\ninstead of treated as a silent \"do not use\", as it would leave the\nuser scratching his or her head without realizing that there is a\ntypo in the configuration file.\n\n> +\t\t\tfi\n> +\t\t\t;;\n> +\t\tesac\n>  \tfi\n>  }\n>\n> base-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n"},{"id":"401080","messageId":"31ab701d65428$b7ca6cd0$275f4670$@zoom.us","threadId":"53430","inReplyTo":"xmqqzh8c8eda.fsf@gitster.c.googlers.com","subject":"RE: [PATCH v9] Support auto-merge for meld to follow the vim-diff behavior","fromName":"","fromEmail":"lin.sun@zoom.us","sentAt":"2020-07-07T06:34:47Z","receivedAt":"2020-07-07T06:34:55Z","isPatch":true,"sender":{"key":"lin.sun@zoom.us","avatar":null},"body":"Hi Junio,\n\nThank you for your comments, and I made the changes in [PATH v10].\nFor `git config --bool ...`, with a `=` appending to the rerere.enabled will get reverse result, here are the commands.\n$ echo [rerere] enabled >> .git/config\n$ git config --bool rerere.enabled\ntrue\n$ echo [rerere] enabled = >> .git/config\n$ git config --bool rerere.enabled\nfalse\n\nSo in [PATH v10], it still try get the string value first, then detecting the \"\"(empty)/true/false/auto. \nThat will cover most cases with one `git config...` calling for useAutoMerge is not configured or is configured properly.\nOtherwise, it will try call `git config --bool ...` for checking more boolean configuration values.\n\nPlease review the [PATH v10], thank you.\nhttps://lore.kernel.org/git/pull.781.v10.git.git.1594102679750.gitgitgadget@gmail.com/\n\nRegards\nLin\n\n"},{"id":"401081","messageId":"31ba101d65429$40d37300$c27a5900$@zoom.us","threadId":"53430","inReplyTo":"xmqqd0577sei.fsf@gitster.c.googlers.com","subject":"RE: [PATCH v10] Support auto-merge for meld to follow the vim-diff behavior","fromName":"","fromEmail":"lin.sun@zoom.us","sentAt":"2020-07-07T06:38:37Z","receivedAt":"2020-07-07T06:38:45Z","isPatch":true,"sender":{"key":"lin.sun@zoom.us","avatar":null},"body":"Hi Junio,\n\nIt seems our mails crossed. I'll read your comments in this mail and reply you later.\n\nLin\n\n-----Original Message-----\nFrom: Junio C Hamano <gitster@pobox.com> \nSent: Tuesday, July 7, 2020 14:26\nTo: sunlin via GitGitGadget <gitgitgadget@gmail.com>\nCc: git@vger.kernel.org; sunlin <sunlin7@yahoo.com>; Lin Sun <lin.sun@zoom.us>\nSubject: Re: [PATCH v10] Support auto-merge for meld to follow the vim-diff behavior\n\n\"sunlin via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> +\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n> +\t\tcase \"$meld_use_auto_merge_option\" in\n> +\t\t\"\")\n> +\t\t\tmeld_use_auto_merge_option=false\n> +\t\t\t;;\n\nI somehow thought that I already pointed out that this is wrong, didn't I?  You cannot tell between a \"[section] var\" (which is\n\"true\") and not having any \"[section] var = val\" (which I think you are trying to treat as \"not configured---do not use\") from the output of \"git config section.var\".\n\nPerhaps our mails crossed?\n\n> +\t\t[Tt]ure|TRUE)\n> +\t\t\tmeld_use_auto_merge_option=true\n> +\t\t\t;;\n> +\t\t[Ff]alse|FALSE)\n> +\t\t\tmeld_use_auto_merge_option=false\n> +\t\t\t;;\n\nThese are probably premature optimizations.\n\n> +\t\t[Aa]uto|AUTO)\n\nSigh.  I somehow thought that I already said we shouldn't do this \"aCCEpt AnY CaSES\" unless all other variables that take 'auto' take it case insensitively.\n\n> +\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n> +\t\t\tinit_meld_help_msg\n> +\n> +\t\t\tcase \"$meld_help_msg\" in\n> +\t\t\t*\"--auto-merge\"*)\n> +\t\t\t\tmeld_use_auto_merge_option=true\n> +\t\t\t\t;;\n> +\t\t\t*)\n> +\t\t\t\tmeld_use_auto_merge_option=false\n> +\t\t\t\t;;\n> +\t\t\tesac\n> +\t\t\t;;\n> +\t\t*)\n> +\t\t\t# try detect boolean for 'on'||'yes'||numberic value\n> +\t\t\tbool_value=$(git config --bool mergetool.meld.useAutoMerge 2>/dev/null)\n> +\t\t\tif test -n \"$bool_value\"\n> +\t\t\tthen\n> +\t\t\t\tmeld_use_auto_merge_option=\"$bool_value\"\n> +\t\t\telse\n> +\t\t\t\tmeld_use_auto_merge_option=false\n\nI think this case (i.e. set to a non-bool value, and we do not recognise because it is not 'auto') should be flagged as an error, instead of treated as a silent \"do not use\", as it would leave the user scratching his or her head without realizing that there is a typo in the configuration file.\n\n> +\t\t\tfi\n> +\t\t\t;;\n> +\t\tesac\n>  \tfi\n>  }\n>\n> base-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n\n"},{"id":"401082","messageId":"31ba201d6542a$01c510a0$054f31e0$@zoom.us","threadId":"53430","inReplyTo":"31ba101d65429$40d37300$c27a5900$@zoom.us","subject":"RE: [PATCH v10] Support auto-merge for meld to follow the vim-diff behavior","fromName":"","fromEmail":"lin.sun@zoom.us","sentAt":"2020-07-07T06:44:01Z","receivedAt":"2020-07-07T06:44:08Z","isPatch":true,"sender":{"key":"lin.sun@zoom.us","avatar":null},"body":"Hi Junio,\n\nI got your points now, I will upload another patch soon.\nThank you.\n\nRegards\nLin\n\n-----Original Message-----\nFrom: lin.sun@zoom.us <lin.sun@zoom.us> \nSent: Tuesday, July 7, 2020 14:39\nTo: 'Junio C Hamano' <gitster@pobox.com>; 'sunlin via GitGitGadget' <gitgitgadget@gmail.com>\nCc: git@vger.kernel.org; 'sunlin' <sunlin7@yahoo.com>\nSubject: RE: [PATCH v10] Support auto-merge for meld to follow the vim-diff behavior\n\nHi Junio,\n\nIt seems our mails crossed. I'll read your comments in this mail and reply you later.\n\nLin\n\n-----Original Message-----\nFrom: Junio C Hamano <gitster@pobox.com> \nSent: Tuesday, July 7, 2020 14:26\nTo: sunlin via GitGitGadget <gitgitgadget@gmail.com>\nCc: git@vger.kernel.org; sunlin <sunlin7@yahoo.com>; Lin Sun <lin.sun@zoom.us>\nSubject: Re: [PATCH v10] Support auto-merge for meld to follow the vim-diff behavior\n\n\"sunlin via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> +\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n> +\t\tcase \"$meld_use_auto_merge_option\" in\n> +\t\t\"\")\n> +\t\t\tmeld_use_auto_merge_option=false\n> +\t\t\t;;\n\nI somehow thought that I already pointed out that this is wrong, didn't I?  You cannot tell between a \"[section] var\" (which is\n\"true\") and not having any \"[section] var = val\" (which I think you are trying to treat as \"not configured---do not use\") from the output of \"git config section.var\".\n\nPerhaps our mails crossed?\n\n> +\t\t[Tt]ure|TRUE)\n> +\t\t\tmeld_use_auto_merge_option=true\n> +\t\t\t;;\n> +\t\t[Ff]alse|FALSE)\n> +\t\t\tmeld_use_auto_merge_option=false\n> +\t\t\t;;\n\nThese are probably premature optimizations.\n\n> +\t\t[Aa]uto|AUTO)\n\nSigh.  I somehow thought that I already said we shouldn't do this \"aCCEpt AnY CaSES\" unless all other variables that take 'auto' take it case insensitively.\n\n> +\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n> +\t\t\tinit_meld_help_msg\n> +\n> +\t\t\tcase \"$meld_help_msg\" in\n> +\t\t\t*\"--auto-merge\"*)\n> +\t\t\t\tmeld_use_auto_merge_option=true\n> +\t\t\t\t;;\n> +\t\t\t*)\n> +\t\t\t\tmeld_use_auto_merge_option=false\n> +\t\t\t\t;;\n> +\t\t\tesac\n> +\t\t\t;;\n> +\t\t*)\n> +\t\t\t# try detect boolean for 'on'||'yes'||numberic value\n> +\t\t\tbool_value=$(git config --bool mergetool.meld.useAutoMerge 2>/dev/null)\n> +\t\t\tif test -n \"$bool_value\"\n> +\t\t\tthen\n> +\t\t\t\tmeld_use_auto_merge_option=\"$bool_value\"\n> +\t\t\telse\n> +\t\t\t\tmeld_use_auto_merge_option=false\n\nI think this case (i.e. set to a non-bool value, and we do not recognise because it is not 'auto') should be flagged as an error, instead of treated as a silent \"do not use\", as it would leave the user scratching his or her head without realizing that there is a typo in the configuration file.\n\n> +\t\t\tfi\n> +\t\t\t;;\n> +\t\tesac\n>  \tfi\n>  }\n>\n> base-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n\n\n"},{"id":"401083","messageId":"pull.781.v11.git.git.1594106024078.gitgitgadget@gmail.com","threadId":"53430","inReplyTo":"pull.781.v10.git.git.1594102679750.gitgitgadget@gmail.com","subject":"[PATCH v11] Support auto-merge for meld to follow the vim-diff behavior","fromName":"sunlin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-07-07T07:13:43Z","receivedAt":"2020-07-07T07:13:48Z","isPatch":true,"sender":{"key":"name:sunlin","avatar":null},"body":"From: Lin Sun <lin.sun@zoom.us>\n\nMake the mergetool used with \"meld\" backend behave similarly to \"vimdiff\" by\ntelling it to auto-merge non-conflicting parts and highlight the conflicting\nparts when `mergetool.meld.useAutoMerge` is configured with `true`, or `auto`\nfor detecting the `--auto-merge` option automatically.\n\nHelped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\nHelped-by: David Aguilar <davvid@gmail.com>\nSigned-off-by: Lin Sun <lin.sun@zoom.us>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n    Enable auto-merge for meld to follow the vimdiff beharior\n    \n    Hi, the mergetool \"meld\" does NOT merge the no-conflict changes, while\n    the mergetool \"vimdiff\" will merge the no-conflict changes and highlight\n    the conflict parts. This patch will make the mergetool \"meld\" similar to\n    \"vimdiff\", auto-merge the no-conflict changes, highlight conflict parts.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-781%2Fsunlin7%2Fmaster-v11\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-781/sunlin7/master-v11\nPull-Request: https://github.com/git/git/pull/781\n\nRange-diff vs v10:\n\n 1:  a4f1b8c2fa ! 1:  8015c4c98e Support auto-merge for meld to follow the vim-diff behavior\n     @@ mergetools/meld: diff_cmd () {\n      -\t\tmeld_has_output_option=true\n      -\telse\n      -\t\tmeld_has_output_option=false\n     -+\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n     -+\t\tcase \"$meld_use_auto_merge_option\" in\n     -+\t\t\"\")\n     -+\t\t\tmeld_use_auto_merge_option=false\n     -+\t\t\t;;\n     -+\t\t[Tt]ure|TRUE)\n     -+\t\t\tmeld_use_auto_merge_option=true\n     -+\t\t\t;;\n     -+\t\t[Ff]alse|FALSE)\n     -+\t\t\tmeld_use_auto_merge_option=false\n     -+\t\t\t;;\n     -+\t\t[Aa]uto|AUTO)\n     -+\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n     -+\t\t\tinit_meld_help_msg\n     -+\n     -+\t\t\tcase \"$meld_help_msg\" in\n     -+\t\t\t*\"--auto-merge\"*)\n     -+\t\t\t\tmeld_use_auto_merge_option=true\n     -+\t\t\t\t;;\n     -+\t\t\t*)\n     -+\t\t\t\tmeld_use_auto_merge_option=false\n     -+\t\t\t\t;;\n     -+\t\t\tesac\n     -+\t\t\t;;\n     -+\t\t*)\n     -+\t\t\t# try detect boolean for 'on'||'yes'||numberic value\n     -+\t\t\tbool_value=$(git config --bool mergetool.meld.useAutoMerge 2>/dev/null)\n     -+\t\t\tif test -n \"$bool_value\"\n     ++\t\tif meld_use_auto_merge_option=$( \\\n     ++\t\t\tgit config --bool mergetool.meld.useAutoMerge 2>/dev/null)\n     ++\t\tthen\n     ++\t\t\t: use configured value\n     ++\t\telse\n     ++\t\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n     ++\t\t\tif test \"$meld_use_auto_merge_option\" = \"auto\"\n      +\t\t\tthen\n     -+\t\t\t\tmeld_use_auto_merge_option=\"$bool_value\"\n     ++\t\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n     ++\t\t\t\tinit_meld_help_msg\n     ++\n     ++\t\t\t\tcase \"$meld_help_msg\" in\n     ++\t\t\t\t*\"--auto-merge\"* | *'[OPTION...]'*)\n     ++\t\t\t\t\tmeld_use_auto_merge_option=true\n     ++\t\t\t\t\t;;\n     ++\t\t\t\t*)\n     ++\t\t\t\t\tmeld_use_auto_merge_option=false\n     ++\t\t\t\t\t;;\n     ++\t\t\t\tesac\n      +\t\t\telse\n      +\t\t\t\tmeld_use_auto_merge_option=false\n      +\t\t\tfi\n     -+\t\t\t;;\n     -+\t\tesac\n     ++\t\tfi\n       \tfi\n       }\n\n\n Documentation/config/mergetool.txt | 10 ++++\n mergetools/meld                    | 81 ++++++++++++++++++++++++------\n 2 files changed, 75 insertions(+), 16 deletions(-)\n\ndiff --git a/Documentation/config/mergetool.txt b/Documentation/config/mergetool.txt\nindex 09ed31dbfa..16a27443a3 100644\n--- a/Documentation/config/mergetool.txt\n+++ b/Documentation/config/mergetool.txt\n@@ -30,6 +30,16 @@ mergetool.meld.hasOutput::\n \tto `true` tells Git to unconditionally use the `--output` option,\n \tand `false` avoids using `--output`.\n \n+mergetool.meld.useAutoMerge::\n+\tWhen the `--auto-merge` is given, meld will merge all non-conflicting\n+\tparts automatically, highlight the conflicting parts and wait for\n+\tuser decision.  Setting `mergetool.meld.useAutoMerge` to `true` tells\n+\tGit to unconditionally use the `--auto-merge` option with `meld`.\n+\tSetting this value to `auto` makes git detect whether `--auto-merge`\n+\tis supported and will only use `--auto-merge` when available.  A\n+\tvalue of `false` avoids using `--auto-merge` altogether, and is the\n+\tdefault value.\n+\n mergetool.keepBackup::\n \tAfter performing a merge, the original file with conflict markers\n \tcan be saved as a file with a `.orig` extension.  If this variable\ndiff --git a/mergetools/meld b/mergetools/meld\nindex 7a08470f88..3463aee87e 100644\n--- a/mergetools/meld\n+++ b/mergetools/meld\n@@ -3,34 +3,83 @@ diff_cmd () {\n }\n \n merge_cmd () {\n-\tif test -z \"${meld_has_output_option:+set}\"\n+\tcheck_meld_for_features\n+\n+\toption_auto_merge=\n+\tif test \"$meld_use_auto_merge_option\" = true\n \tthen\n-\t\tcheck_meld_for_output_version\n+\t\toption_auto_merge=\"--auto-merge\"\n \tfi\n \n \tif test \"$meld_has_output_option\" = true\n \tthen\n-\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n+\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \telse\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \tfi\n }\n \n-# Check whether we should use 'meld --output <file>'\n-check_meld_for_output_version () {\n-\tmeld_path=\"$(git config mergetool.meld.path)\"\n-\tmeld_path=\"${meld_path:-meld}\"\n+# Get meld help message\n+init_meld_help_msg () {\n+\tif test -z \"$meld_help_msg\"\n+\tthen\n+\t\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n+\t\tmeld_help_msg=$($meld_path --help 2>&1)\n+\tfi\n+}\n \n-\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+# Check the features and set flags\n+check_meld_for_features () {\n+\t# Check whether we should use 'meld --output <file>'\n+\tif test -z \"$meld_has_output_option\"\n \tthen\n-\t\t: use configured value\n-\telif \"$meld_path\" --help 2>&1 |\n-\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n+\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+\t\tcase \"$meld_has_output_option\" in\n+\t\ttrue|false)\n+\t\t\t: use configured value\n+\t\t\t;;\n+\t\t*)\n+\t\t\t: empty or invalid configured value, detecting \"--output\" automatically\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--output=\"* | *'[OPTION...]'*)\n+\t\t\t\t# All version that has [OPTION...] supports --output\n+\t\t\t\tmeld_has_output_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_has_output_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\tesac\n+\tfi\n+\t# Check whether we should use 'meld --auto-merge ...'\n+\tif test -z \"$meld_use_auto_merge_option\"\n \tthen\n-\t\t: old ones mention --output and new ones just say OPTION...\n-\t\tmeld_has_output_option=true\n-\telse\n-\t\tmeld_has_output_option=false\n+\t\tif meld_use_auto_merge_option=$( \\\n+\t\t\tgit config --bool mergetool.meld.useAutoMerge 2>/dev/null)\n+\t\tthen\n+\t\t\t: use configured value\n+\t\telse\n+\t\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n+\t\t\tif test \"$meld_use_auto_merge_option\" = \"auto\"\n+\t\t\tthen\n+\t\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n+\t\t\t\tinit_meld_help_msg\n+\n+\t\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t\t*\"--auto-merge\"* | *'[OPTION...]'*)\n+\t\t\t\t\tmeld_use_auto_merge_option=true\n+\t\t\t\t\t;;\n+\t\t\t\t*)\n+\t\t\t\t\tmeld_use_auto_merge_option=false\n+\t\t\t\t\t;;\n+\t\t\t\tesac\n+\t\t\telse\n+\t\t\t\tmeld_use_auto_merge_option=false\n+\t\t\tfi\n+\t\tfi\n \tfi\n }\n\nbase-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n-- \ngitgitgadget\n"},{"id":"401127","messageId":"20200707153155.GC7003@danh.dev","threadId":"53430","inReplyTo":"pull.781.v11.git.git.1594106024078.gitgitgadget@gmail.com","subject":"Re: [PATCH v11] Support auto-merge for meld to follow the vim-diff behavior","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-07-07T15:31:55Z","receivedAt":"2020-07-07T15:32:02Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-07-07 07:13:43+0000, sunlin via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> -# Check whether we should use 'meld --output <file>'\n> -check_meld_for_output_version () {\n> -\tmeld_path=\"$(git config mergetool.meld.path)\"\n> -\tmeld_path=\"${meld_path:-meld}\"\n> +# Get meld help message\n> +init_meld_help_msg () {\n> +\tif test -z \"$meld_help_msg\"\n> +\tthen\n> +\t\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n> +\t\tmeld_help_msg=$($meld_path --help 2>&1)\n\nI haven't thought about this until now.\n`$meld_path` should be quoted.\n\n\tmeld_help_msg=\"$(\"$meld_path\" --help 2>&1)\"\n\nEither that or our Windows friends will complain soon:\n\n\tC:/Program Files/Meld/meld --help\n\n(I don't know where meld will be installed by default in Window exactly,\nabove command is just a guess)\n\n> +\tfi\n> +}\n>  \n> -\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n> +# Check the features and set flags\n> +check_meld_for_features () {\n> +\t# Check whether we should use 'meld --output <file>'\n> +\tif test -z \"$meld_has_output_option\"\n>  \tthen\n> -\t\t: use configured value\n> -\telif \"$meld_path\" --help 2>&1 |\n> -\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n> +\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n> +\t\tcase \"$meld_has_output_option\" in\n> +\t\ttrue|false)\n> +\t\t\t: use configured value\n> +\t\t\t;;\n> +\t\t*)\n> +\t\t\t: empty or invalid configured value, detecting \"--output\" automatically\n> +\t\t\tinit_meld_help_msg\n> +\n> +\t\t\tcase \"$meld_help_msg\" in\n> +\t\t\t*\"--output=\"* | *'[OPTION...]'*)\n> +\t\t\t\t# All version that has [OPTION...] supports --output\n\nGood comments :)\n\n> +\t\t\t\tmeld_has_output_option=true\n> +\t\t\t\t;;\n> +\t\t\t*)\n> +\t\t\t\tmeld_has_output_option=false\n> +\t\t\t\t;;\n> +\t\t\tesac\n> +\t\t\t;;\n> +\t\tesac\n> +\tfi\n> +\t# Check whether we should use 'meld --auto-merge ...'\n> +\tif test -z \"$meld_use_auto_merge_option\"\n>  \tthen\n> -\t\t: old ones mention --output and new ones just say OPTION...\n> -\t\tmeld_has_output_option=true\n> -\telse\n> -\t\tmeld_has_output_option=false\n> +\t\tif meld_use_auto_merge_option=$( \\\n> +\t\t\tgit config --bool mergetool.meld.useAutoMerge 2>/dev/null)\n> +\t\tthen\n> +\t\t\t: use configured value\n> +\t\telse\n> +\t\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n> +\t\t\tif test \"$meld_use_auto_merge_option\" = \"auto\"\n> +\t\t\tthen\n> +\t\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n> +\t\t\t\tinit_meld_help_msg\n> +\n> +\t\t\t\tcase \"$meld_help_msg\" in\n> +\t\t\t\t*\"--auto-merge\"* | *'[OPTION...]'*)\n> +\t\t\t\t\tmeld_use_auto_merge_option=true\n> +\t\t\t\t\t;;\n> +\t\t\t\t*)\n> +\t\t\t\t\tmeld_use_auto_merge_option=false\n> +\t\t\t\t\t;;\n> +\t\t\t\tesac\n> +\t\t\telse\n> +\t\t\t\tmeld_use_auto_merge_option=false\n\nIf I read other emails correctly (which I usually don't),\nI think we would want to bail out in this case.\n\n> +\t\t\tfi\n> +\t\tfi\n>  \tfi\n>  }\n> \n> base-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n> -- \n> gitgitgadget\n\n-- \nDanh\n"},{"id":"401130","messageId":"xmqqmu4b5l8l.fsf@gitster.c.googlers.com","threadId":"53430","inReplyTo":"31ab701d65428$b7ca6cd0$275f4670$@zoom.us","subject":"Re: [PATCH v9] Support auto-merge for meld to follow the vim-diff behavior","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-07-07T16:43:38Z","receivedAt":"2020-07-07T16:43:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"<lin.sun@zoom.us> writes:\n\n> So in [PATH v10], it still try get the string value first, then detecting the \"\"(empty)/true/false/auto. \n\nYou cannot interpret an empty output from \"git config section.variable\";\nit could be \"[section] variable\" (which is true), or it could be a sign\nthat there is no \"[section] variable = value\" in the configuration (which\nyou treat as false).\n\nCatching common spellings of 'true' and 'false' in the output of the\nstring version of \"git config\", while checking for 'auto' at the\nsame time, may not be too bad as an optimization to save an extra\ncall to \"git config --bool 2>/dev/null\" (and ignoring errors), so I\nam OK with that as long as you leave the empty output alone.\n"},{"id":"401170","messageId":"015101d654c2$c43032d0$4c909870$@zoom.us","threadId":"53430","inReplyTo":"20200707153155.GC7003@danh.dev","subject":"RE: [PATCH v11] Support auto-merge for meld to follow the vim-diff behavior","fromName":"","fromEmail":"lin.sun@zoom.us","sentAt":"2020-07-08T00:57:31Z","receivedAt":"2020-07-08T00:57:38Z","isPatch":true,"sender":{"key":"lin.sun@zoom.us","avatar":null},"body":"Hi Doah,\n\n>`$meld_path` should be quoted.\n>...\nYes, you're totally right, I'll fix the `$meld_path` and more changes will upload with the [PATCH v12].\nI'll update to you when the patch is ready. \n\nRegards\nLin\n\n"},{"id":"401171","messageId":"04e201d654c6$016bfb40$0443f1c0$@zoom.us","threadId":"53430","inReplyTo":"xmqqmu4b5l8l.fsf@gitster.c.googlers.com","subject":"RE: [PATCH v9] Support auto-merge for meld to follow the vim-diff behavior","fromName":"","fromEmail":"lin.sun@zoom.us","sentAt":"2020-07-08T01:20:40Z","receivedAt":"2020-07-08T01:20:54Z","isPatch":true,"sender":{"key":"lin.sun@zoom.us","avatar":null},"body":"Hi Junio,\n\n> You cannot interpret an empty output from \"git config section.variable\"; it could be \"[section] variable\" (which is true), or it could be a sign that there is no \"[section] variable = value\" in the configuration (which you treat as false)\n\nYes, I notice that both \"[section] variable \" and \"[section] variable = \" output empty string but have reverse Boolean value.\n\n> Catching common spellings of 'true' and 'false' in the output of the string version of \"git config\", while checking for 'auto' at the same time, may not be too bad as an optimization to save an extra call to \"git config --bool 2>/dev/null\" (and ignoring errors)...\n\nWith preview point, ` git config --bool ...` would better than \"not be too bad\"  : )\n\nWith the return code and return string from ` git config --bool ...`, \nfollow pseudo-code maybe good for current situation.\nif meld_use_auto_merge_option =` git config --bool ...`\nthen\n\t# success, maybe \"(empty)\"/true/false\n\tif test -z \"$ meld_use_auto_merge_option\"\n\tthen\n\t\tmeld_use_auto_merge_option=false\n\tfi\nelse\n\t# failed, the option is not empty or Boolean\n\tif test \"auto\" = ` git config `\n\tthen\n\t\t# detect the \"--auto-merge\" option\n\telse\n\t\tmeld_use_auto_merge_option=false\n\tfi\nfi\n\nChanges will upload with the [PATCH v12].\nI'll update to you when the patch is ready. \n\nRegards\nLin\n\n"},{"id":"401172","messageId":"xmqqeepm3hap.fsf@gitster.c.googlers.com","threadId":"53430","inReplyTo":"04e201d654c6$016bfb40$0443f1c0$@zoom.us","subject":"Re: [PATCH v9] Support auto-merge for meld to follow the vim-diff behavior","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-07-08T01:51:42Z","receivedAt":"2020-07-08T01:51:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"<lin.sun@zoom.us> writes:\n\n> if meld_use_auto_merge_option =` git config --bool ...`\n> then\n> \t# success, maybe \"(empty)\"/true/false\n> \tif test -z \"$ meld_use_auto_merge_option\"\n> \tthen\n> \t\tmeld_use_auto_merge_option=false\n> \tfi\n\nThe inner test does not make any sense to me; I doubt that you can\nget an empty output from a \"git config --bool\" that succeeds.\n\n     $ cat >config <<\\EOF\n     [x] a\n         b=true\n         c=1\n         d=false\n         e=no\n\t f=bogus\n     EOF\n     $ for i in a b c d e f\n       do\n         if v=$(git config --file=config --bool x.$i 2>/dev/null)\n         then\n           echo \"succeeds (x.$i) => '$v'\"\n         else\n           echo \"fails (x.$i) => '$v'\"\n         fi\n       done\n\nYou should see\n\nsucceeds (x.a) => 'true'\nsucceeds (x.b) => 'true'\nsucceeds (x.c) => 'true'\nsucceeds (x.d) => 'false'\nsucceeds (x.e) => 'false'\nfails (x.f) => ''\n\nif you run the above.  The most interesting is how all boolean\nvalues are normalized to true and false regardless of how they are\noriginally spelled.\n\n> else\n> \t# failed, the option is not empty or Boolean\n> \tif test \"auto\" = ` git config `\n> \tthen\n> \t\t# detect the \"--auto-merge\" option\n> \telse\n> \t\tmeld_use_auto_merge_option=false\n\nI think review by Đoàn pointed out that we would want to warn/fail\nloudly in this \"else\" case, as it is likely a misspelt configuration\nvalue?\n\nTo recap, I think something along the following lines would be the\nmost readable and acceptably efficient with a short-cut for the\ncommon cases.\n\n    var=mergetool.meld.whatever\n    val=$(git config $var)\n    case \"$val\" in\n    true | false)\n\t# we can take a short-cut without asking config --bool\n        ... use $val ...\n\t;;\n    auto)\n\t... auto detect ...\n\t;;\n    *)\n\tif val=$(git config --bool $var 2>/dev/null)\n\tthen\n\t\t# succeeded, so val must be a normalized boolean\n\t\t... use $val ...\n\telse\n\t\tdie cannot parse $var\n\tfi\n    easc\n\nThanks.\n"},{"id":"401173","messageId":"pull.781.v12.git.git.1594178716840.gitgitgadget@gmail.com","threadId":"53430","inReplyTo":"pull.781.v11.git.git.1594106024078.gitgitgadget@gmail.com","subject":"[PATCH v12] Support auto-merge for meld to follow the vim-diff behavior","fromName":"sunlin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-07-08T03:25:16Z","receivedAt":"2020-07-08T03:25:23Z","isPatch":true,"sender":{"key":"name:sunlin","avatar":null},"body":"From: Lin Sun <lin.sun@zoom.us>\n\nMake the mergetool used with \"meld\" backend behave similarly to \"vimdiff\" by\ntelling it to auto-merge non-conflicting parts and highlight the conflicting\nparts when `mergetool.meld.useAutoMerge` is configured with `true`, or `auto`\nfor detecting the `--auto-merge` option automatically.\n\nHelped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\nHelped-by: David Aguilar <davvid@gmail.com>\nSigned-off-by: Lin Sun <lin.sun@zoom.us>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n    Enable auto-merge for meld to follow the vimdiff beharior\n    \n    Hi, the mergetool \"meld\" does NOT merge the no-conflict changes, while\n    the mergetool \"vimdiff\" will merge the no-conflict changes and highlight\n    the conflict parts. This patch will make the mergetool \"meld\" similar to\n    \"vimdiff\", auto-merge the no-conflict changes, highlight conflict parts.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-781%2Fsunlin7%2Fmaster-v12\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-781/sunlin7/master-v12\nPull-Request: https://github.com/git/git/pull/781\n\nRange-diff vs v11:\n\n 1:  8015c4c98e ! 1:  b130cf38b5 Support auto-merge for meld to follow the vim-diff behavior\n     @@ mergetools/meld: diff_cmd () {\n      +\tif test -z \"$meld_help_msg\"\n      +\tthen\n      +\t\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n     -+\t\tmeld_help_msg=$($meld_path --help 2>&1)\n     ++\t\tmeld_help_msg=$(\"$meld_path\" --help 2>&1)\n      +\tfi\n      +}\n       \n     @@ mergetools/meld: diff_cmd () {\n      +\t\t\tinit_meld_help_msg\n      +\n      +\t\t\tcase \"$meld_help_msg\" in\n     -+\t\t\t*\"--output=\"* | *'[OPTION...]'*)\n     ++\t\t\t*\"--output=\"*|*'[OPTION...]'*)\n      +\t\t\t\t# All version that has [OPTION...] supports --output\n      +\t\t\t\tmeld_has_output_option=true\n      +\t\t\t\t;;\n     @@ mergetools/meld: diff_cmd () {\n      -\t\tmeld_has_output_option=true\n      -\telse\n      -\t\tmeld_has_output_option=false\n     -+\t\tif meld_use_auto_merge_option=$( \\\n     -+\t\t\tgit config --bool mergetool.meld.useAutoMerge 2>/dev/null)\n     -+\t\tthen\n     -+\t\t\t: use configured value\n     -+\t\telse\n     -+\t\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n     -+\t\t\tif test \"$meld_use_auto_merge_option\" = \"auto\"\n     -+\t\t\tthen\n     -+\t\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n     -+\t\t\t\tinit_meld_help_msg\n     ++\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n     ++\t\tcase \"$meld_use_auto_merge_option\" in\n     ++\t\ttrue|false)\n     ++\t\t\t: use well formatted boolean value\n     ++\t\t\t;;\n     ++\t\tauto)\n     ++\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n     ++\t\t\tinit_meld_help_msg\n      +\n     -+\t\t\t\tcase \"$meld_help_msg\" in\n     -+\t\t\t\t*\"--auto-merge\"* | *'[OPTION...]'*)\n     -+\t\t\t\t\tmeld_use_auto_merge_option=true\n     -+\t\t\t\t\t;;\n     -+\t\t\t\t*)\n     -+\t\t\t\t\tmeld_use_auto_merge_option=false\n     -+\t\t\t\t\t;;\n     -+\t\t\t\tesac\n     ++\t\t\tcase \"$meld_help_msg\" in\n     ++\t\t\t*\"--auto-merge\"*|*'[OPTION...]')\n     ++\t\t\t\tmeld_use_auto_merge_option=true\n     ++\t\t\t\t;;\n     ++\t\t\t*)\n     ++\t\t\t\tmeld_use_auto_merge_option=false\n     ++\t\t\t\t;;\n     ++\t\t\tesac\n     ++\t\t\t;;\n     ++\t\t*)\n     ++\t\t\tif meld_use_auto_merge_option=$(\\\n     ++\t\t\t\t git config --bool mergetool.meld.useAutoMerge)\n     ++\t\t\tthen\n     ++\t\t\t\t: use normalized boolean value\n      +\t\t\telse\n      +\t\t\t\tmeld_use_auto_merge_option=false\n      +\t\t\tfi\n     -+\t\tfi\n     ++\t\t\t;;\n     ++\t\tesac\n       \tfi\n       }\n\n\n Documentation/config/mergetool.txt | 10 ++++\n mergetools/meld                    | 86 ++++++++++++++++++++++++------\n 2 files changed, 80 insertions(+), 16 deletions(-)\n\ndiff --git a/Documentation/config/mergetool.txt b/Documentation/config/mergetool.txt\nindex 09ed31dbfa..16a27443a3 100644\n--- a/Documentation/config/mergetool.txt\n+++ b/Documentation/config/mergetool.txt\n@@ -30,6 +30,16 @@ mergetool.meld.hasOutput::\n \tto `true` tells Git to unconditionally use the `--output` option,\n \tand `false` avoids using `--output`.\n \n+mergetool.meld.useAutoMerge::\n+\tWhen the `--auto-merge` is given, meld will merge all non-conflicting\n+\tparts automatically, highlight the conflicting parts and wait for\n+\tuser decision.  Setting `mergetool.meld.useAutoMerge` to `true` tells\n+\tGit to unconditionally use the `--auto-merge` option with `meld`.\n+\tSetting this value to `auto` makes git detect whether `--auto-merge`\n+\tis supported and will only use `--auto-merge` when available.  A\n+\tvalue of `false` avoids using `--auto-merge` altogether, and is the\n+\tdefault value.\n+\n mergetool.keepBackup::\n \tAfter performing a merge, the original file with conflict markers\n \tcan be saved as a file with a `.orig` extension.  If this variable\ndiff --git a/mergetools/meld b/mergetools/meld\nindex 7a08470f88..d71c22196d 100644\n--- a/mergetools/meld\n+++ b/mergetools/meld\n@@ -3,34 +3,88 @@ diff_cmd () {\n }\n \n merge_cmd () {\n-\tif test -z \"${meld_has_output_option:+set}\"\n+\tcheck_meld_for_features\n+\n+\toption_auto_merge=\n+\tif test \"$meld_use_auto_merge_option\" = true\n \tthen\n-\t\tcheck_meld_for_output_version\n+\t\toption_auto_merge=\"--auto-merge\"\n \tfi\n \n \tif test \"$meld_has_output_option\" = true\n \tthen\n-\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n+\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \telse\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \tfi\n }\n \n-# Check whether we should use 'meld --output <file>'\n-check_meld_for_output_version () {\n-\tmeld_path=\"$(git config mergetool.meld.path)\"\n-\tmeld_path=\"${meld_path:-meld}\"\n+# Get meld help message\n+init_meld_help_msg () {\n+\tif test -z \"$meld_help_msg\"\n+\tthen\n+\t\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n+\t\tmeld_help_msg=$(\"$meld_path\" --help 2>&1)\n+\tfi\n+}\n \n-\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+# Check the features and set flags\n+check_meld_for_features () {\n+\t# Check whether we should use 'meld --output <file>'\n+\tif test -z \"$meld_has_output_option\"\n \tthen\n-\t\t: use configured value\n-\telif \"$meld_path\" --help 2>&1 |\n-\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n+\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+\t\tcase \"$meld_has_output_option\" in\n+\t\ttrue|false)\n+\t\t\t: use configured value\n+\t\t\t;;\n+\t\t*)\n+\t\t\t: empty or invalid configured value, detecting \"--output\" automatically\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--output=\"*|*'[OPTION...]'*)\n+\t\t\t\t# All version that has [OPTION...] supports --output\n+\t\t\t\tmeld_has_output_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_has_output_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\tesac\n+\tfi\n+\t# Check whether we should use 'meld --auto-merge ...'\n+\tif test -z \"$meld_use_auto_merge_option\"\n \tthen\n-\t\t: old ones mention --output and new ones just say OPTION...\n-\t\tmeld_has_output_option=true\n-\telse\n-\t\tmeld_has_output_option=false\n+\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n+\t\tcase \"$meld_use_auto_merge_option\" in\n+\t\ttrue|false)\n+\t\t\t: use well formatted boolean value\n+\t\t\t;;\n+\t\tauto)\n+\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--auto-merge\"*|*'[OPTION...]')\n+\t\t\t\tmeld_use_auto_merge_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_use_auto_merge_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\t*)\n+\t\t\tif meld_use_auto_merge_option=$(\\\n+\t\t\t\t git config --bool mergetool.meld.useAutoMerge)\n+\t\t\tthen\n+\t\t\t\t: use normalized boolean value\n+\t\t\telse\n+\t\t\t\tmeld_use_auto_merge_option=false\n+\t\t\tfi\n+\t\t\t;;\n+\t\tesac\n \tfi\n }\n\nbase-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n-- \ngitgitgadget\n"},{"id":"401174","messageId":"089101d654d8$55503fc0$fff0bf40$@zoom.us","threadId":"53430","inReplyTo":"pull.781.v12.git.git.1594178716840.gitgitgadget@gmail.com","subject":"RE: [PATCH v12] Support auto-merge for meld to follow the vim-diff behavior","fromName":"","fromEmail":"lin.sun@zoom.us","sentAt":"2020-07-08T03:31:53Z","receivedAt":"2020-07-08T03:32:02Z","isPatch":true,"sender":{"key":"lin.sun@zoom.us","avatar":null},"body":"Hi Junio, Doah,\n\nThe [PATCH v12] Is uploaded, in which,\n1. \"$meld_path\" is quoted.\n2. the logical for deal true/false/auto is flow Junio's comment\n3. error message will emit for invalid configuration value\n$ git config mergetool.meld.useAutoMerge invalid_boolean_value\n$ git mergetool --tool=meld\n...\nfatal: bad numeric config value 'hello' for 'mergetool.meld.useautomerge' in .git/config: invalid unit\n\nPlease review again, thank you.\nhttps://lore.kernel.org/git/pull.781.v12.git.git.1594178716840.gitgitgadget@gmail.com/\n\nRegards\nLin\n\n"},{"id":"401187","messageId":"20200708154218.GB18432@danh.dev","threadId":"53430","inReplyTo":"pull.781.v12.git.git.1594178716840.gitgitgadget@gmail.com","subject":"Re: [PATCH v12] Support auto-merge for meld to follow the vim-diff behavior","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-07-08T15:42:18Z","receivedAt":"2020-07-08T15:42:30Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-07-08 03:25:16+0000, sunlin via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> +\t# Check whether we should use 'meld --auto-merge ...'\n> +\tif test -z \"$meld_use_auto_merge_option\"\n>  \tthen\n> -\t\t: old ones mention --output and new ones just say OPTION...\n> -\t\tmeld_has_output_option=true\n> -\telse\n> -\t\tmeld_has_output_option=false\n> +\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n> +\t\tcase \"$meld_use_auto_merge_option\" in\n> +\t\ttrue|false)\n> +\t\t\t: use well formatted boolean value\n> +\t\t\t;;\n> +\t\tauto)\n> +\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n> +\t\t\tinit_meld_help_msg\n> +\n> +\t\t\tcase \"$meld_help_msg\" in\n> +\t\t\t*\"--auto-merge\"*|*'[OPTION...]')\n\nThe \"*'[OPTION...]'*\" part sneaks into here in v11,\nAnd this version drops the last \"*\",\nwhich makes it:\n\n- less correct if all versions that has \"[OPTION...]\" supports\n  --auto-merge, which is unlikely; and\n- less incorrect (still not correct enough) if some versions\n  that has \"[OPTION...]\" doesn't support --auto-merge,\n  which is more likely.\n\nIf we could trace all versions of meld and confirms the former\ncondition, I think it's better to add back the missing \"*\"\n\nOtherwise, it's safer choice to remove \"|*'[OPTION...]\" here.\n\nI'm not using meld, so, if someone asked me, I would go with the latter.\n\n\n-- \nDanh\n"},{"id":"401190","messageId":"009301d6553f$138237d0$3a86a770$@zoom.us","threadId":"53430","inReplyTo":"20200708154218.GB18432@danh.dev","subject":"RE: [PATCH v12] Support auto-merge for meld to follow the vim-diff behavior","fromName":"","fromEmail":"lin.sun@zoom.us","sentAt":"2020-07-08T15:47:20Z","receivedAt":"2020-07-08T15:47:29Z","isPatch":true,"sender":{"key":"lin.sun@zoom.us","avatar":null},"body":"Hi Danh,\n\nThank you for your comment, it's actually my failed that loss the \"*\" after *\"[OPTIONS...]\".\nI'll add back the missing '*' in next uploading.\n\nRegards\nLin\n\n"},{"id":"401209","messageId":"pull.781.v13.git.git.1594254906647.gitgitgadget@gmail.com","threadId":"53430","inReplyTo":"pull.781.v12.git.git.1594178716840.gitgitgadget@gmail.com","subject":"[PATCH v13] Support auto-merge for meld to follow the vim-diff behavior","fromName":"sunlin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-07-09T00:35:06Z","receivedAt":"2020-07-09T00:35:10Z","isPatch":true,"sender":{"key":"name:sunlin","avatar":null},"body":"From: Lin Sun <lin.sun@zoom.us>\n\nMake the mergetool used with \"meld\" backend behave similarly to \"vimdiff\" by\ntelling it to auto-merge non-conflicting parts and highlight the conflicting\nparts when `mergetool.meld.useAutoMerge` is configured with `true`, or `auto`\nfor detecting the `--auto-merge` option automatically.\n\nHelped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\nHelped-by: David Aguilar <davvid@gmail.com>\nSigned-off-by: Lin Sun <lin.sun@zoom.us>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n    Enable auto-merge for meld to follow the vimdiff beharior\n    \n    Hi, the mergetool \"meld\" does NOT merge the no-conflict changes, while\n    the mergetool \"vimdiff\" will merge the no-conflict changes and highlight\n    the conflict parts. This patch will make the mergetool \"meld\" similar to\n    \"vimdiff\", auto-merge the no-conflict changes, highlight conflict parts.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-781%2Fsunlin7%2Fmaster-v13\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-781/sunlin7/master-v13\nPull-Request: https://github.com/git/git/pull/781\n\nRange-diff vs v12:\n\n 1:  b130cf38b5 ! 1:  b949e5721a Support auto-merge for meld to follow the vim-diff behavior\n     @@ mergetools/meld: diff_cmd () {\n      +\t\t\tinit_meld_help_msg\n      +\n      +\t\t\tcase \"$meld_help_msg\" in\n     -+\t\t\t*\"--auto-merge\"*|*'[OPTION...]')\n     ++\t\t\t*\"--auto-merge\"*|*'[OPTION...]'*)\n      +\t\t\t\tmeld_use_auto_merge_option=true\n      +\t\t\t\t;;\n      +\t\t\t*)\n\n\n Documentation/config/mergetool.txt | 10 ++++\n mergetools/meld                    | 86 ++++++++++++++++++++++++------\n 2 files changed, 80 insertions(+), 16 deletions(-)\n\ndiff --git a/Documentation/config/mergetool.txt b/Documentation/config/mergetool.txt\nindex 09ed31dbfa..16a27443a3 100644\n--- a/Documentation/config/mergetool.txt\n+++ b/Documentation/config/mergetool.txt\n@@ -30,6 +30,16 @@ mergetool.meld.hasOutput::\n \tto `true` tells Git to unconditionally use the `--output` option,\n \tand `false` avoids using `--output`.\n \n+mergetool.meld.useAutoMerge::\n+\tWhen the `--auto-merge` is given, meld will merge all non-conflicting\n+\tparts automatically, highlight the conflicting parts and wait for\n+\tuser decision.  Setting `mergetool.meld.useAutoMerge` to `true` tells\n+\tGit to unconditionally use the `--auto-merge` option with `meld`.\n+\tSetting this value to `auto` makes git detect whether `--auto-merge`\n+\tis supported and will only use `--auto-merge` when available.  A\n+\tvalue of `false` avoids using `--auto-merge` altogether, and is the\n+\tdefault value.\n+\n mergetool.keepBackup::\n \tAfter performing a merge, the original file with conflict markers\n \tcan be saved as a file with a `.orig` extension.  If this variable\ndiff --git a/mergetools/meld b/mergetools/meld\nindex 7a08470f88..5e5872e1c3 100644\n--- a/mergetools/meld\n+++ b/mergetools/meld\n@@ -3,34 +3,88 @@ diff_cmd () {\n }\n \n merge_cmd () {\n-\tif test -z \"${meld_has_output_option:+set}\"\n+\tcheck_meld_for_features\n+\n+\toption_auto_merge=\n+\tif test \"$meld_use_auto_merge_option\" = true\n \tthen\n-\t\tcheck_meld_for_output_version\n+\t\toption_auto_merge=\"--auto-merge\"\n \tfi\n \n \tif test \"$meld_has_output_option\" = true\n \tthen\n-\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n+\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \telse\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \tfi\n }\n \n-# Check whether we should use 'meld --output <file>'\n-check_meld_for_output_version () {\n-\tmeld_path=\"$(git config mergetool.meld.path)\"\n-\tmeld_path=\"${meld_path:-meld}\"\n+# Get meld help message\n+init_meld_help_msg () {\n+\tif test -z \"$meld_help_msg\"\n+\tthen\n+\t\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n+\t\tmeld_help_msg=$(\"$meld_path\" --help 2>&1)\n+\tfi\n+}\n \n-\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+# Check the features and set flags\n+check_meld_for_features () {\n+\t# Check whether we should use 'meld --output <file>'\n+\tif test -z \"$meld_has_output_option\"\n \tthen\n-\t\t: use configured value\n-\telif \"$meld_path\" --help 2>&1 |\n-\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n+\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+\t\tcase \"$meld_has_output_option\" in\n+\t\ttrue|false)\n+\t\t\t: use configured value\n+\t\t\t;;\n+\t\t*)\n+\t\t\t: empty or invalid configured value, detecting \"--output\" automatically\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--output=\"*|*'[OPTION...]'*)\n+\t\t\t\t# All version that has [OPTION...] supports --output\n+\t\t\t\tmeld_has_output_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_has_output_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\tesac\n+\tfi\n+\t# Check whether we should use 'meld --auto-merge ...'\n+\tif test -z \"$meld_use_auto_merge_option\"\n \tthen\n-\t\t: old ones mention --output and new ones just say OPTION...\n-\t\tmeld_has_output_option=true\n-\telse\n-\t\tmeld_has_output_option=false\n+\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n+\t\tcase \"$meld_use_auto_merge_option\" in\n+\t\ttrue|false)\n+\t\t\t: use well formatted boolean value\n+\t\t\t;;\n+\t\tauto)\n+\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--auto-merge\"*|*'[OPTION...]'*)\n+\t\t\t\tmeld_use_auto_merge_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_use_auto_merge_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\t*)\n+\t\t\tif meld_use_auto_merge_option=$(\\\n+\t\t\t\t git config --bool mergetool.meld.useAutoMerge)\n+\t\t\tthen\n+\t\t\t\t: use normalized boolean value\n+\t\t\telse\n+\t\t\t\tmeld_use_auto_merge_option=false\n+\t\t\tfi\n+\t\t\t;;\n+\t\tesac\n \tfi\n }\n\nbase-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n-- \ngitgitgadget\n"},{"id":"401210","messageId":"1f0901d65589$7858bbd0$690a3370$@zoom.us","threadId":"53430","inReplyTo":"pull.781.v13.git.git.1594254906647.gitgitgadget@gmail.com","subject":"[PATCH v13] Support auto-merge for meld to follow the vim-diff behavior","fromName":"","fromEmail":"lin.sun@zoom.us","sentAt":"2020-07-09T00:39:53Z","receivedAt":"2020-07-09T00:40:03Z","isPatch":true,"sender":{"key":"lin.sun@zoom.us","avatar":null},"body":"Hi Danh,\n\nThe [PATCH v13] add the missing \"*\" back at the back of *'[OPTION...]'.\n     -+\t\t\t*\"--auto-merge\"*|*'[OPTION...]')\n     ++\t\t\t*\"--auto-merge\"*|*'[OPTION...]'*)\n\nhttps://lore.kernel.org/git/pull.781.v13.git.git.1594254906647.gitgitgadget@gmail.com\nThanks\n\nRegards\nLin\n\n"},{"id":"401225","messageId":"xmqqlfjtz9vx.fsf@gitster.c.googlers.com","threadId":"53430","inReplyTo":"pull.781.v13.git.git.1594254906647.gitgitgadget@gmail.com","subject":"Re: [PATCH v13] Support auto-merge for meld to follow the vim-diff behavior","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-07-09T02:42:58Z","receivedAt":"2020-07-09T02:43:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"sunlin via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Lin Sun <lin.sun@zoom.us>\n> Subject: Re: [PATCH v13] Support auto-merge for meld to follow the vim-diff behavior\n\nI'd retitle to match the recommended structure, e.g.\n\n    Subject: [PATCH] mergetool: update meld backend to allow using '--auto-merge'\n\nwhile queuing.\n\nThanks.  I might have more comments later.\n"},{"id":"401226","messageId":"xmqqh7uhz98q.fsf@gitster.c.googlers.com","threadId":"53430","inReplyTo":"pull.781.v13.git.git.1594254906647.gitgitgadget@gmail.com","subject":"Re: [PATCH v13] Support auto-merge for meld to follow the vim-diff behavior","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-07-09T02:56:53Z","receivedAt":"2020-07-09T02:57:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"sunlin via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> +\t\t\tcase \"$meld_help_msg\" in\n> +\t\t\t*\"--output=\"*|*'[OPTION...]'*)\n\nThis may be personal preference, but I think the way you spelled\nthis line with SP on both sides of '|' was much easier to read.\n\n> +\t# Check whether we should use 'meld --auto-merge ...'\n> +\tif test -z \"$meld_use_auto_merge_option\"\n>  \tthen\n> +\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n> +\t\tcase \"$meld_use_auto_merge_option\" in\n> +\t\ttrue|false)\n> +\t\t\t: use well formatted boolean value\n> +\t\t\t;;\n\nOK.\n\n> +\t\tauto)\n> +\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n> +\t\t\tinit_meld_help_msg\n> +\n> +\t\t\tcase \"$meld_help_msg\" in\n> +\t\t\t*\"--auto-merge\"*|*'[OPTION...]'*)\n> +\t\t\t\tmeld_use_auto_merge_option=true\n> +\t\t\t\t;;\n> +\t\t\t*)\n> +\t\t\t\tmeld_use_auto_merge_option=false\n> +\t\t\t\t;;\n> +\t\t\tesac\n> +\t\t\t;;\n\nOK.\n\n> +\t\t*)\n\nThis is the case where we saw \"\", \"True\", \"treu\", etc. from the\nstring \"git config --get\".\n\n> +\t\t\tif meld_use_auto_merge_option=$(\\\n> +\t\t\t\t git config --bool mergetool.meld.useAutoMerge)\n\nYou do not need that backslash, do you?\n\nPerhaps\n\n\t\t\tif meld_use_auto_merge_option=$(\n\t\t\t\t git config --bool mergetool.meld.useAutoMerge\n\t\t\t)\t\n\t\t\tthen\n\nif you really want to spread them into multiple lines.\n\n> +\t\t\tthen\n> +\t\t\t\t: use normalized boolean value\n\nSure, we got a valid boolean.\n\n> +\t\t\telse\n> +\t\t\t\tmeld_use_auto_merge_option=false\n\nWhy? Shoudln't we loudly complain to let the user know of a misspelt\nvalue in the configuration?\n\n> +\t\t\tfi\n> +\t\t\t;;\n> +\t\tesac\n>  \tfi\n>  }\n>\n> base-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n"},{"id":"401227","messageId":"261a01d655a0$71077210$53165630$@zoom.us","threadId":"53430","inReplyTo":"xmqqh7uhz98q.fsf@gitster.c.googlers.com","subject":"RE: [PATCH v13] Support auto-merge for meld to follow the vim-diff behavior","fromName":"","fromEmail":"lin.sun@zoom.us","sentAt":"2020-07-09T03:24:20Z","receivedAt":"2020-07-09T03:24:30Z","isPatch":true,"sender":{"key":"lin.sun@zoom.us","avatar":null},"body":"Hi Junio,\n\nI'll add SP on both side of  '|', and remove the backslash, thank you.\n\nThis line assign value with `git config --bool...` is over 80 characters, so there is a break. \n\n>> +\t\t\telse\n>> +\t\t\t\tmeld_use_auto_merge_option=false\n>Why? Shoudln't we loudly complain to let the user know of a misspelt value in the configuration?\n\nThe command line `git config --bool ...` without \"2>&/dev/null\" will print error message, just passthrough to user.\n$ git config mergetool.meld.useAutoMerge hello \n$ git mergetool --tool=meld \nfatal: bad numeric config value 'hello' for 'mergetool.meld.useautomerge' in .git/config: invalid unit\n\nI'll upload the changes soon.\n\nRegards\nLin\n\n"},{"id":"401229","messageId":"pull.781.v14.git.git.1594268906195.gitgitgadget@gmail.com","threadId":"53430","inReplyTo":"pull.781.v13.git.git.1594254906647.gitgitgadget@gmail.com","subject":"[PATCH v14] Support auto-merge for meld to follow the vim-diff behavior","fromName":"sunlin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-07-09T04:28:26Z","receivedAt":"2020-07-09T04:28:31Z","isPatch":true,"sender":{"key":"name:sunlin","avatar":null},"body":"From: Lin Sun <lin.sun@zoom.us>\n\nMake the mergetool used with \"meld\" backend behave similarly to \"vimdiff\" by\ntelling it to auto-merge non-conflicting parts and highlight the conflicting\nparts when `mergetool.meld.useAutoMerge` is configured with `true`, or `auto`\nfor detecting the `--auto-merge` option automatically.\n\nHelped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\nHelped-by: David Aguilar <davvid@gmail.com>\nSigned-off-by: Lin Sun <lin.sun@zoom.us>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n    Enable auto-merge for meld to follow the vimdiff beharior\n    \n    Hi, the mergetool \"meld\" does NOT merge the no-conflict changes, while\n    the mergetool \"vimdiff\" will merge the no-conflict changes and highlight\n    the conflict parts. This patch will make the mergetool \"meld\" similar to\n    \"vimdiff\", auto-merge the no-conflict changes, highlight conflict parts.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-781%2Fsunlin7%2Fmaster-v14\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-781/sunlin7/master-v14\nPull-Request: https://github.com/git/git/pull/781\n\nRange-diff vs v13:\n\n 1:  b949e5721a ! 1:  ce4e4cbfc0 Support auto-merge for meld to follow the vim-diff behavior\n     @@ mergetools/meld: diff_cmd () {\n      +\t\t\tesac\n      +\t\t\t;;\n      +\t\t*)\n     -+\t\t\tif meld_use_auto_merge_option=$(\\\n     ++\t\t\t# try other boolean value with git\n     ++\t\t\tif meld_use_auto_merge_option=$(\n      +\t\t\t\t git config --bool mergetool.meld.useAutoMerge)\n      +\t\t\tthen\n      +\t\t\t\t: use normalized boolean value\n\n\n Documentation/config/mergetool.txt | 10 ++++\n mergetools/meld                    | 87 ++++++++++++++++++++++++------\n 2 files changed, 81 insertions(+), 16 deletions(-)\n\ndiff --git a/Documentation/config/mergetool.txt b/Documentation/config/mergetool.txt\nindex 09ed31dbfa..16a27443a3 100644\n--- a/Documentation/config/mergetool.txt\n+++ b/Documentation/config/mergetool.txt\n@@ -30,6 +30,16 @@ mergetool.meld.hasOutput::\n \tto `true` tells Git to unconditionally use the `--output` option,\n \tand `false` avoids using `--output`.\n \n+mergetool.meld.useAutoMerge::\n+\tWhen the `--auto-merge` is given, meld will merge all non-conflicting\n+\tparts automatically, highlight the conflicting parts and wait for\n+\tuser decision.  Setting `mergetool.meld.useAutoMerge` to `true` tells\n+\tGit to unconditionally use the `--auto-merge` option with `meld`.\n+\tSetting this value to `auto` makes git detect whether `--auto-merge`\n+\tis supported and will only use `--auto-merge` when available.  A\n+\tvalue of `false` avoids using `--auto-merge` altogether, and is the\n+\tdefault value.\n+\n mergetool.keepBackup::\n \tAfter performing a merge, the original file with conflict markers\n \tcan be saved as a file with a `.orig` extension.  If this variable\ndiff --git a/mergetools/meld b/mergetools/meld\nindex 7a08470f88..d95b4ee630 100644\n--- a/mergetools/meld\n+++ b/mergetools/meld\n@@ -3,34 +3,89 @@ diff_cmd () {\n }\n \n merge_cmd () {\n-\tif test -z \"${meld_has_output_option:+set}\"\n+\tcheck_meld_for_features\n+\n+\toption_auto_merge=\n+\tif test \"$meld_use_auto_merge_option\" = true\n \tthen\n-\t\tcheck_meld_for_output_version\n+\t\toption_auto_merge=\"--auto-merge\"\n \tfi\n \n \tif test \"$meld_has_output_option\" = true\n \tthen\n-\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n+\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \telse\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \tfi\n }\n \n-# Check whether we should use 'meld --output <file>'\n-check_meld_for_output_version () {\n-\tmeld_path=\"$(git config mergetool.meld.path)\"\n-\tmeld_path=\"${meld_path:-meld}\"\n+# Get meld help message\n+init_meld_help_msg () {\n+\tif test -z \"$meld_help_msg\"\n+\tthen\n+\t\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n+\t\tmeld_help_msg=$(\"$meld_path\" --help 2>&1)\n+\tfi\n+}\n \n-\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+# Check the features and set flags\n+check_meld_for_features () {\n+\t# Check whether we should use 'meld --output <file>'\n+\tif test -z \"$meld_has_output_option\"\n \tthen\n-\t\t: use configured value\n-\telif \"$meld_path\" --help 2>&1 |\n-\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n+\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+\t\tcase \"$meld_has_output_option\" in\n+\t\ttrue|false)\n+\t\t\t: use configured value\n+\t\t\t;;\n+\t\t*)\n+\t\t\t: empty or invalid configured value, detecting \"--output\" automatically\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--output=\"*|*'[OPTION...]'*)\n+\t\t\t\t# All version that has [OPTION...] supports --output\n+\t\t\t\tmeld_has_output_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_has_output_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\tesac\n+\tfi\n+\t# Check whether we should use 'meld --auto-merge ...'\n+\tif test -z \"$meld_use_auto_merge_option\"\n \tthen\n-\t\t: old ones mention --output and new ones just say OPTION...\n-\t\tmeld_has_output_option=true\n-\telse\n-\t\tmeld_has_output_option=false\n+\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n+\t\tcase \"$meld_use_auto_merge_option\" in\n+\t\ttrue|false)\n+\t\t\t: use well formatted boolean value\n+\t\t\t;;\n+\t\tauto)\n+\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--auto-merge\"*|*'[OPTION...]'*)\n+\t\t\t\tmeld_use_auto_merge_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_use_auto_merge_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\t*)\n+\t\t\t# try other boolean value with git\n+\t\t\tif meld_use_auto_merge_option=$(\n+\t\t\t\t git config --bool mergetool.meld.useAutoMerge)\n+\t\t\tthen\n+\t\t\t\t: use normalized boolean value\n+\t\t\telse\n+\t\t\t\tmeld_use_auto_merge_option=false\n+\t\t\tfi\n+\t\t\t;;\n+\t\tesac\n \tfi\n }\n\nbase-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n-- \ngitgitgadget\n"},{"id":"401230","messageId":"xmqqd055z40h.fsf@gitster.c.googlers.com","threadId":"53430","inReplyTo":"261a01d655a0$71077210$53165630$@zoom.us","subject":"Re: [PATCH v13] Support auto-merge for meld to follow the vim-diff behavior","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-07-09T04:49:50Z","receivedAt":"2020-07-09T04:49:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"<lin.sun@zoom.us> writes:\n\n> Hi Junio,\n>\n> I'll add SP on both side of  '|', and remove the backslash, thank you.\n>\n> This line assign value with `git config --bool...` is over 80 characters, so there is a break. \n>\n>>> +\t\t\telse\n>>> +\t\t\t\tmeld_use_auto_merge_option=false\n>>Why? Shoudln't we loudly complain to let the user know of a misspelt value in the configuration?\n>\n> The command line `git config --bool ...` without \"2>&/dev/null\" will print error message, just passthrough to user.\n> $ git config mergetool.meld.useAutoMerge hello \n> $ git mergetool --tool=meld \n> fatal: bad numeric config value 'hello' for 'mergetool.meld.useautomerge' in .git/config: invalid unit\n\nYes, but you do not exit(1) here, so the user will keep going\nwithout having a chance to stop, think and correct the misspelt\nvalue in the configuration file, no?\n\n>\n> I'll upload the changes soon.\n>\n> Regards\n> Lin\n"},{"id":"401231","messageId":"xmqq8sftz23v.fsf@gitster.c.googlers.com","threadId":"53430","inReplyTo":"xmqqd055z40h.fsf@gitster.c.googlers.com","subject":"Re: [PATCH v13] Support auto-merge for meld to follow the vim-diff behavior","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-07-09T05:31:00Z","receivedAt":"2020-07-09T05:31:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n>>>> +\t\t\telse\n>>>> +\t\t\t\tmeld_use_auto_merge_option=false\n>>>Why? Shoudln't we loudly complain to let the user know of a misspelt value in the configuration?\n>>\n>> The command line `git config --bool ...` without \"2>&/dev/null\" will print error message, just passthrough to user.\n>> $ git config mergetool.meld.useAutoMerge hello \n>> $ git mergetool --tool=meld \n>> fatal: bad numeric config value 'hello' for 'mergetool.meld.useautomerge' in .git/config: invalid unit\n>\n> Yes, but you do not exit(1) here, so the user will keep going\n> without having a chance to stop, think and correct the misspelt\n> value in the configuration file, no?\n\nHmph, I've been forgetting an important case you are handling well,\nwhich is that the user does not have the variable defined anywhere\nin the configuration.  \"git config --bool var.ia.ble\" fails silently\nin such a case, and you do want to declare that the user does not\nwant to use the \"--auto-merge\" in that case, which is what this\nsilent else clause does very well.\n\nSo, let's leave this part as-is.\n\nThanks, I'll push out a new iteration of today's integration before\ngoing to bed.\n\n>\n>>\n>> I'll upload the changes soon.\n>>\n>> Regards\n>> Lin\n"},{"id":"401405","messageId":"pull.781.v15.git.git.1594543148959.gitgitgadget@gmail.com","threadId":"53430","inReplyTo":"pull.781.v14.git.git.1594268906195.gitgitgadget@gmail.com","subject":"[PATCH v15] Support auto-merge for meld to follow the vim-diff behavior","fromName":"sunlin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-07-12T08:39:08Z","receivedAt":"2020-07-12T08:39:30Z","isPatch":true,"sender":{"key":"name:sunlin","avatar":null},"body":"From: Lin Sun <lin.sun@zoom.us>\n\nMake the mergetool used with \"meld\" backend behave similarly to \"vimdiff\" by\ntelling it to auto-merge non-conflicting parts and highlight the conflicting\nparts when `mergetool.meld.useAutoMerge` is configured with `true`, or `auto`\nfor detecting the `--auto-merge` option automatically.\n\nHelped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\nHelped-by: David Aguilar <davvid@gmail.com>\nSigned-off-by: Lin Sun <lin.sun@zoom.us>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n    Enable auto-merge for meld to follow the vimdiff beharior\n    \n    Hi, the mergetool \"meld\" does NOT merge the no-conflict changes, while\n    the mergetool \"vimdiff\" will merge the no-conflict changes and highlight\n    the conflict parts. This patch will make the mergetool \"meld\" similar to\n    \"vimdiff\", auto-merge the no-conflict changes, highlight conflict parts.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-781%2Fsunlin7%2Fmaster-v15\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-781/sunlin7/master-v15\nPull-Request: https://github.com/git/git/pull/781\n\nRange-diff vs v14:\n\n 1:  ce4e4cbfc0 ! 1:  02d849784f Support auto-merge for meld to follow the vim-diff behavior\n     @@ Documentation/config/mergetool.txt: mergetool.meld.hasOutput::\n       \tAfter performing a merge, the original file with conflict markers\n       \tcan be saved as a file with a `.orig` extension.  If this variable\n      \n     + ## builtin/config.c ##\n     +@@ builtin/config.c: static int show_scope;\n     + #define TYPE_PATH\t\t4\n     + #define TYPE_EXPIRY_DATE\t5\n     + #define TYPE_COLOR\t\t6\n     ++#define TYPE_BOOL_OR_STR        7\n     + \n     + #define OPT_CALLBACK_VALUE(s, l, v, h, i) \\\n     + \t{ OPTION_CALLBACK, (s), (l), (v), NULL, (h), PARSE_OPT_NOARG | \\\n     +@@ builtin/config.c: static int option_parse_type(const struct option *opt, const char *arg,\n     + \t\t\tnew_type = TYPE_INT;\n     + \t\telse if (!strcmp(arg, \"bool-or-int\"))\n     + \t\t\tnew_type = TYPE_BOOL_OR_INT;\n     ++\t\telse if (!strcmp(arg, \"bool-or-str\"))\n     ++\t\t\tnew_type = TYPE_BOOL_OR_STR;\n     + \t\telse if (!strcmp(arg, \"path\"))\n     + \t\t\tnew_type = TYPE_PATH;\n     + \t\telse if (!strcmp(arg, \"expiry-date\"))\n     +@@ builtin/config.c: static struct option builtin_config_options[] = {\n     + \tOPT_CALLBACK_VALUE(0, \"bool\", &type, N_(\"value is \\\"true\\\" or \\\"false\\\"\"), TYPE_BOOL),\n     + \tOPT_CALLBACK_VALUE(0, \"int\", &type, N_(\"value is decimal number\"), TYPE_INT),\n     + \tOPT_CALLBACK_VALUE(0, \"bool-or-int\", &type, N_(\"value is --bool or --int\"), TYPE_BOOL_OR_INT),\n     ++\tOPT_CALLBACK_VALUE(0, \"bool-or-str\", &type, N_(\"value is --bool or string\"), TYPE_BOOL_OR_STR),\n     + \tOPT_CALLBACK_VALUE(0, \"path\", &type, N_(\"value is a path (file or directory name)\"), TYPE_PATH),\n     + \tOPT_CALLBACK_VALUE(0, \"expiry-date\", &type, N_(\"value is an expiry date\"), TYPE_EXPIRY_DATE),\n     + \tOPT_GROUP(N_(\"Other\")),\n     +@@ builtin/config.c: static int format_config(struct strbuf *buf, const char *key_, const char *value\n     + \t\t\t\tstrbuf_addstr(buf, v ? \"true\" : \"false\");\n     + \t\t\telse\n     + \t\t\t\tstrbuf_addf(buf, \"%d\", v);\n     ++\t\t} else if (type == TYPE_BOOL_OR_STR) {\n     ++\t\t\tint is_bool, v;\n     ++\t\t\tv = git_config_bool_or_str(NULL, key_, value_, &is_bool);\n     ++\t\t\tif (is_bool)\n     ++\t\t\t\tstrbuf_addstr(buf, v ? \"true\" : \"false\");\n     ++\t\t\telse\n     ++\t\t\t\tstrbuf_addstr(buf, value_);\n     + \t\t} else if (type == TYPE_PATH) {\n     + \t\t\tconst char *v;\n     + \t\t\tif (git_config_pathname(&v, key_, value_) < 0)\n     +@@ builtin/config.c: static char *normalize_value(const char *key, const char *value)\n     + \t\telse\n     + \t\t\treturn xstrdup(v ? \"true\" : \"false\");\n     + \t}\n     ++\tif (type == TYPE_BOOL_OR_STR) {\n     ++\t\tint is_bool, v;\n     ++\t\tv = git_config_bool_or_str(NULL, key, value, &is_bool);\n     ++\t\tif (!is_bool)\n     ++\t\t\treturn xstrdup(value);\n     ++\t\telse\n     ++\t\t\treturn xstrdup(v ? \"true\" : \"false\");\n     ++\t}\n     + \tif (type == TYPE_COLOR) {\n     + \t\tchar v[COLOR_MAXLEN];\n     + \t\tif (git_config_color(v, key, value))\n     +\n     + ## config.c ##\n     +@@ config.c: int git_config_bool_or_int(const char *name, const char *value, int *is_bool)\n     + \treturn git_config_int(name, value);\n     + }\n     + \n     ++int git_config_bool_or_str(const char **dest, const char *name, const char *value, int *is_bool)\n     ++{\n     ++\tint v = git_parse_maybe_bool_text(value);\n     ++\tif (0 <= v) {\n     ++\t\t*is_bool = 1;\n     ++\t\treturn v;\n     ++\t}\n     ++\t*is_bool = 0;\n     ++\tif (dest != NULL)\n     ++\t  return git_config_string(dest, name, value);\n     ++\telse\n     ++\t  return 0;\n     ++}\n     ++\n     + int git_config_bool(const char *name, const char *value)\n     + {\n     + \tint discard;\n     +\n     + ## config.h ##\n     +@@ config.h: ssize_t git_config_ssize_t(const char *, const char *);\n     +  */\n     + int git_config_bool_or_int(const char *, const char *, int *);\n     + \n     ++/**\n     ++ * Same as `git_config_bool`, except that `is_bool` flag is unset, then if\n     ++ * `dest` parameter is non-NULL, it allocates and copies the value string\n     ++ * into the `dest`, if `dest` is NULL and `is_bool` flag is unset it return 0.\n     ++ */\n     ++int git_config_bool_or_str(const char **, const char *, const char *, int *);\n     ++\n     + /**\n     +  * Parse a string into a boolean value, respecting keywords like \"true\" and\n     +  * \"false\". Integer values are converted into true/false values (when they\n     +\n       ## mergetools/meld ##\n      @@ mergetools/meld: diff_cmd () {\n       }\n     @@ mergetools/meld: diff_cmd () {\n      -\t\tmeld_has_output_option=true\n      -\telse\n      -\t\tmeld_has_output_option=false\n     -+\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n     ++\t\tmeld_use_auto_merge_option=$(\n     ++\t\t\tgit --bool-or-str config mergetool.meld.useAutoMerge)\n      +\t\tcase \"$meld_use_auto_merge_option\" in\n      +\t\ttrue|false)\n      +\t\t\t: use well formatted boolean value\n     @@ mergetools/meld: diff_cmd () {\n      +\t\t\tesac\n      +\t\t\t;;\n      +\t\t*)\n     -+\t\t\t# try other boolean value with git\n     -+\t\t\tif meld_use_auto_merge_option=$(\n     -+\t\t\t\t git config --bool mergetool.meld.useAutoMerge)\n     -+\t\t\tthen\n     -+\t\t\t\t: use normalized boolean value\n     -+\t\t\telse\n     -+\t\t\t\tmeld_use_auto_merge_option=false\n     -+\t\t\tfi\n     ++\t\t\tmeld_use_auto_merge_option=false\n      +\t\t\t;;\n      +\t\tesac\n       \tfi\n\n\n Documentation/config/mergetool.txt | 10 ++++\n builtin/config.c                   | 19 +++++++\n config.c                           | 14 ++++++\n config.h                           |  7 +++\n mergetools/meld                    | 81 ++++++++++++++++++++++++------\n 5 files changed, 115 insertions(+), 16 deletions(-)\n\ndiff --git a/Documentation/config/mergetool.txt b/Documentation/config/mergetool.txt\nindex 09ed31dbfa..16a27443a3 100644\n--- a/Documentation/config/mergetool.txt\n+++ b/Documentation/config/mergetool.txt\n@@ -30,6 +30,16 @@ mergetool.meld.hasOutput::\n \tto `true` tells Git to unconditionally use the `--output` option,\n \tand `false` avoids using `--output`.\n \n+mergetool.meld.useAutoMerge::\n+\tWhen the `--auto-merge` is given, meld will merge all non-conflicting\n+\tparts automatically, highlight the conflicting parts and wait for\n+\tuser decision.  Setting `mergetool.meld.useAutoMerge` to `true` tells\n+\tGit to unconditionally use the `--auto-merge` option with `meld`.\n+\tSetting this value to `auto` makes git detect whether `--auto-merge`\n+\tis supported and will only use `--auto-merge` when available.  A\n+\tvalue of `false` avoids using `--auto-merge` altogether, and is the\n+\tdefault value.\n+\n mergetool.keepBackup::\n \tAfter performing a merge, the original file with conflict markers\n \tcan be saved as a file with a `.orig` extension.  If this variable\ndiff --git a/builtin/config.c b/builtin/config.c\nindex ee4aef6a35..6f2ddadc80 100644\n--- a/builtin/config.c\n+++ b/builtin/config.c\n@@ -65,6 +65,7 @@ static int show_scope;\n #define TYPE_PATH\t\t4\n #define TYPE_EXPIRY_DATE\t5\n #define TYPE_COLOR\t\t6\n+#define TYPE_BOOL_OR_STR        7\n \n #define OPT_CALLBACK_VALUE(s, l, v, h, i) \\\n \t{ OPTION_CALLBACK, (s), (l), (v), NULL, (h), PARSE_OPT_NOARG | \\\n@@ -94,6 +95,8 @@ static int option_parse_type(const struct option *opt, const char *arg,\n \t\t\tnew_type = TYPE_INT;\n \t\telse if (!strcmp(arg, \"bool-or-int\"))\n \t\t\tnew_type = TYPE_BOOL_OR_INT;\n+\t\telse if (!strcmp(arg, \"bool-or-str\"))\n+\t\t\tnew_type = TYPE_BOOL_OR_STR;\n \t\telse if (!strcmp(arg, \"path\"))\n \t\t\tnew_type = TYPE_PATH;\n \t\telse if (!strcmp(arg, \"expiry-date\"))\n@@ -149,6 +152,7 @@ static struct option builtin_config_options[] = {\n \tOPT_CALLBACK_VALUE(0, \"bool\", &type, N_(\"value is \\\"true\\\" or \\\"false\\\"\"), TYPE_BOOL),\n \tOPT_CALLBACK_VALUE(0, \"int\", &type, N_(\"value is decimal number\"), TYPE_INT),\n \tOPT_CALLBACK_VALUE(0, \"bool-or-int\", &type, N_(\"value is --bool or --int\"), TYPE_BOOL_OR_INT),\n+\tOPT_CALLBACK_VALUE(0, \"bool-or-str\", &type, N_(\"value is --bool or string\"), TYPE_BOOL_OR_STR),\n \tOPT_CALLBACK_VALUE(0, \"path\", &type, N_(\"value is a path (file or directory name)\"), TYPE_PATH),\n \tOPT_CALLBACK_VALUE(0, \"expiry-date\", &type, N_(\"value is an expiry date\"), TYPE_EXPIRY_DATE),\n \tOPT_GROUP(N_(\"Other\")),\n@@ -250,6 +254,13 @@ static int format_config(struct strbuf *buf, const char *key_, const char *value\n \t\t\t\tstrbuf_addstr(buf, v ? \"true\" : \"false\");\n \t\t\telse\n \t\t\t\tstrbuf_addf(buf, \"%d\", v);\n+\t\t} else if (type == TYPE_BOOL_OR_STR) {\n+\t\t\tint is_bool, v;\n+\t\t\tv = git_config_bool_or_str(NULL, key_, value_, &is_bool);\n+\t\t\tif (is_bool)\n+\t\t\t\tstrbuf_addstr(buf, v ? \"true\" : \"false\");\n+\t\t\telse\n+\t\t\t\tstrbuf_addstr(buf, value_);\n \t\t} else if (type == TYPE_PATH) {\n \t\t\tconst char *v;\n \t\t\tif (git_config_pathname(&v, key_, value_) < 0)\n@@ -411,6 +422,14 @@ static char *normalize_value(const char *key, const char *value)\n \t\telse\n \t\t\treturn xstrdup(v ? \"true\" : \"false\");\n \t}\n+\tif (type == TYPE_BOOL_OR_STR) {\n+\t\tint is_bool, v;\n+\t\tv = git_config_bool_or_str(NULL, key, value, &is_bool);\n+\t\tif (!is_bool)\n+\t\t\treturn xstrdup(value);\n+\t\telse\n+\t\t\treturn xstrdup(v ? \"true\" : \"false\");\n+\t}\n \tif (type == TYPE_COLOR) {\n \t\tchar v[COLOR_MAXLEN];\n \t\tif (git_config_color(v, key, value))\ndiff --git a/config.c b/config.c\nindex 8db9c77098..4c6c06d10b 100644\n--- a/config.c\n+++ b/config.c\n@@ -1100,6 +1100,20 @@ int git_config_bool_or_int(const char *name, const char *value, int *is_bool)\n \treturn git_config_int(name, value);\n }\n \n+int git_config_bool_or_str(const char **dest, const char *name, const char *value, int *is_bool)\n+{\n+\tint v = git_parse_maybe_bool_text(value);\n+\tif (0 <= v) {\n+\t\t*is_bool = 1;\n+\t\treturn v;\n+\t}\n+\t*is_bool = 0;\n+\tif (dest != NULL)\n+\t  return git_config_string(dest, name, value);\n+\telse\n+\t  return 0;\n+}\n+\n int git_config_bool(const char *name, const char *value)\n {\n \tint discard;\ndiff --git a/config.h b/config.h\nindex 060874488f..175b88d9c5 100644\n--- a/config.h\n+++ b/config.h\n@@ -217,6 +217,13 @@ ssize_t git_config_ssize_t(const char *, const char *);\n  */\n int git_config_bool_or_int(const char *, const char *, int *);\n \n+/**\n+ * Same as `git_config_bool`, except that `is_bool` flag is unset, then if\n+ * `dest` parameter is non-NULL, it allocates and copies the value string\n+ * into the `dest`, if `dest` is NULL and `is_bool` flag is unset it return 0.\n+ */\n+int git_config_bool_or_str(const char **, const char *, const char *, int *);\n+\n /**\n  * Parse a string into a boolean value, respecting keywords like \"true\" and\n  * \"false\". Integer values are converted into true/false values (when they\ndiff --git a/mergetools/meld b/mergetools/meld\nindex 7a08470f88..1838a8c35b 100644\n--- a/mergetools/meld\n+++ b/mergetools/meld\n@@ -3,34 +3,83 @@ diff_cmd () {\n }\n \n merge_cmd () {\n-\tif test -z \"${meld_has_output_option:+set}\"\n+\tcheck_meld_for_features\n+\n+\toption_auto_merge=\n+\tif test \"$meld_use_auto_merge_option\" = true\n \tthen\n-\t\tcheck_meld_for_output_version\n+\t\toption_auto_merge=\"--auto-merge\"\n \tfi\n \n \tif test \"$meld_has_output_option\" = true\n \tthen\n-\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n+\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \telse\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \tfi\n }\n \n-# Check whether we should use 'meld --output <file>'\n-check_meld_for_output_version () {\n-\tmeld_path=\"$(git config mergetool.meld.path)\"\n-\tmeld_path=\"${meld_path:-meld}\"\n+# Get meld help message\n+init_meld_help_msg () {\n+\tif test -z \"$meld_help_msg\"\n+\tthen\n+\t\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n+\t\tmeld_help_msg=$(\"$meld_path\" --help 2>&1)\n+\tfi\n+}\n \n-\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+# Check the features and set flags\n+check_meld_for_features () {\n+\t# Check whether we should use 'meld --output <file>'\n+\tif test -z \"$meld_has_output_option\"\n \tthen\n-\t\t: use configured value\n-\telif \"$meld_path\" --help 2>&1 |\n-\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n+\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+\t\tcase \"$meld_has_output_option\" in\n+\t\ttrue|false)\n+\t\t\t: use configured value\n+\t\t\t;;\n+\t\t*)\n+\t\t\t: empty or invalid configured value, detecting \"--output\" automatically\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--output=\"*|*'[OPTION...]'*)\n+\t\t\t\t# All version that has [OPTION...] supports --output\n+\t\t\t\tmeld_has_output_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_has_output_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\tesac\n+\tfi\n+\t# Check whether we should use 'meld --auto-merge ...'\n+\tif test -z \"$meld_use_auto_merge_option\"\n \tthen\n-\t\t: old ones mention --output and new ones just say OPTION...\n-\t\tmeld_has_output_option=true\n-\telse\n-\t\tmeld_has_output_option=false\n+\t\tmeld_use_auto_merge_option=$(\n+\t\t\tgit --bool-or-str config mergetool.meld.useAutoMerge)\n+\t\tcase \"$meld_use_auto_merge_option\" in\n+\t\ttrue|false)\n+\t\t\t: use well formatted boolean value\n+\t\t\t;;\n+\t\tauto)\n+\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--auto-merge\"*|*'[OPTION...]'*)\n+\t\t\t\tmeld_use_auto_merge_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_use_auto_merge_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\t*)\n+\t\t\tmeld_use_auto_merge_option=false\n+\t\t\t;;\n+\t\tesac\n \tfi\n }\n\nbase-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n-- \ngitgitgadget\n"},{"id":"401406","messageId":"pull.781.v16.git.git.1594544903477.gitgitgadget@gmail.com","threadId":"53430","inReplyTo":"pull.781.v15.git.git.1594543148959.gitgitgadget@gmail.com","subject":"[PATCH v16] Support auto-merge for meld to follow the vim-diff behavior","fromName":"sunlin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-07-12T09:08:23Z","receivedAt":"2020-07-12T09:08:28Z","isPatch":true,"sender":{"key":"name:sunlin","avatar":null},"body":"From: Lin Sun <lin.sun@zoom.us>\n\nMake the mergetool used with \"meld\" backend behave similarly to \"vimdiff\" by\ntelling it to auto-merge non-conflicting parts and highlight the conflicting\nparts when `mergetool.meld.useAutoMerge` is configured with `true`, or `auto`\nfor detecting the `--auto-merge` option automatically.\n\nHelped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\nHelped-by: David Aguilar <davvid@gmail.com>\nSigned-off-by: Lin Sun <lin.sun@zoom.us>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n    Enable auto-merge for meld to follow the vimdiff beharior\n    \n    Hi, the mergetool \"meld\" does NOT merge the no-conflict changes, while\n    the mergetool \"vimdiff\" will merge the no-conflict changes and highlight\n    the conflict parts. This patch will make the mergetool \"meld\" similar to\n    \"vimdiff\", auto-merge the no-conflict changes, highlight conflict parts.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-781%2Fsunlin7%2Fmaster-v16\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-781/sunlin7/master-v16\nPull-Request: https://github.com/git/git/pull/781\n\nRange-diff vs v15:\n\n 1:  02d849784f ! 1:  d235a576b4 Support auto-merge for meld to follow the vim-diff behavior\n     @@ mergetools/meld: diff_cmd () {\n      -\telse\n      -\t\tmeld_has_output_option=false\n      +\t\tmeld_use_auto_merge_option=$(\n     -+\t\t\tgit --bool-or-str config mergetool.meld.useAutoMerge)\n     ++\t\t\tgit config --bool-or-str mergetool.meld.useAutoMerge)\n      +\t\tcase \"$meld_use_auto_merge_option\" in\n      +\t\ttrue|false)\n      +\t\t\t: use well formatted boolean value\n\n\n Documentation/config/mergetool.txt | 10 ++++\n builtin/config.c                   | 19 +++++++\n config.c                           | 14 ++++++\n config.h                           |  7 +++\n mergetools/meld                    | 81 ++++++++++++++++++++++++------\n 5 files changed, 115 insertions(+), 16 deletions(-)\n\ndiff --git a/Documentation/config/mergetool.txt b/Documentation/config/mergetool.txt\nindex 09ed31dbfa..16a27443a3 100644\n--- a/Documentation/config/mergetool.txt\n+++ b/Documentation/config/mergetool.txt\n@@ -30,6 +30,16 @@ mergetool.meld.hasOutput::\n \tto `true` tells Git to unconditionally use the `--output` option,\n \tand `false` avoids using `--output`.\n \n+mergetool.meld.useAutoMerge::\n+\tWhen the `--auto-merge` is given, meld will merge all non-conflicting\n+\tparts automatically, highlight the conflicting parts and wait for\n+\tuser decision.  Setting `mergetool.meld.useAutoMerge` to `true` tells\n+\tGit to unconditionally use the `--auto-merge` option with `meld`.\n+\tSetting this value to `auto` makes git detect whether `--auto-merge`\n+\tis supported and will only use `--auto-merge` when available.  A\n+\tvalue of `false` avoids using `--auto-merge` altogether, and is the\n+\tdefault value.\n+\n mergetool.keepBackup::\n \tAfter performing a merge, the original file with conflict markers\n \tcan be saved as a file with a `.orig` extension.  If this variable\ndiff --git a/builtin/config.c b/builtin/config.c\nindex ee4aef6a35..6f2ddadc80 100644\n--- a/builtin/config.c\n+++ b/builtin/config.c\n@@ -65,6 +65,7 @@ static int show_scope;\n #define TYPE_PATH\t\t4\n #define TYPE_EXPIRY_DATE\t5\n #define TYPE_COLOR\t\t6\n+#define TYPE_BOOL_OR_STR        7\n \n #define OPT_CALLBACK_VALUE(s, l, v, h, i) \\\n \t{ OPTION_CALLBACK, (s), (l), (v), NULL, (h), PARSE_OPT_NOARG | \\\n@@ -94,6 +95,8 @@ static int option_parse_type(const struct option *opt, const char *arg,\n \t\t\tnew_type = TYPE_INT;\n \t\telse if (!strcmp(arg, \"bool-or-int\"))\n \t\t\tnew_type = TYPE_BOOL_OR_INT;\n+\t\telse if (!strcmp(arg, \"bool-or-str\"))\n+\t\t\tnew_type = TYPE_BOOL_OR_STR;\n \t\telse if (!strcmp(arg, \"path\"))\n \t\t\tnew_type = TYPE_PATH;\n \t\telse if (!strcmp(arg, \"expiry-date\"))\n@@ -149,6 +152,7 @@ static struct option builtin_config_options[] = {\n \tOPT_CALLBACK_VALUE(0, \"bool\", &type, N_(\"value is \\\"true\\\" or \\\"false\\\"\"), TYPE_BOOL),\n \tOPT_CALLBACK_VALUE(0, \"int\", &type, N_(\"value is decimal number\"), TYPE_INT),\n \tOPT_CALLBACK_VALUE(0, \"bool-or-int\", &type, N_(\"value is --bool or --int\"), TYPE_BOOL_OR_INT),\n+\tOPT_CALLBACK_VALUE(0, \"bool-or-str\", &type, N_(\"value is --bool or string\"), TYPE_BOOL_OR_STR),\n \tOPT_CALLBACK_VALUE(0, \"path\", &type, N_(\"value is a path (file or directory name)\"), TYPE_PATH),\n \tOPT_CALLBACK_VALUE(0, \"expiry-date\", &type, N_(\"value is an expiry date\"), TYPE_EXPIRY_DATE),\n \tOPT_GROUP(N_(\"Other\")),\n@@ -250,6 +254,13 @@ static int format_config(struct strbuf *buf, const char *key_, const char *value\n \t\t\t\tstrbuf_addstr(buf, v ? \"true\" : \"false\");\n \t\t\telse\n \t\t\t\tstrbuf_addf(buf, \"%d\", v);\n+\t\t} else if (type == TYPE_BOOL_OR_STR) {\n+\t\t\tint is_bool, v;\n+\t\t\tv = git_config_bool_or_str(NULL, key_, value_, &is_bool);\n+\t\t\tif (is_bool)\n+\t\t\t\tstrbuf_addstr(buf, v ? \"true\" : \"false\");\n+\t\t\telse\n+\t\t\t\tstrbuf_addstr(buf, value_);\n \t\t} else if (type == TYPE_PATH) {\n \t\t\tconst char *v;\n \t\t\tif (git_config_pathname(&v, key_, value_) < 0)\n@@ -411,6 +422,14 @@ static char *normalize_value(const char *key, const char *value)\n \t\telse\n \t\t\treturn xstrdup(v ? \"true\" : \"false\");\n \t}\n+\tif (type == TYPE_BOOL_OR_STR) {\n+\t\tint is_bool, v;\n+\t\tv = git_config_bool_or_str(NULL, key, value, &is_bool);\n+\t\tif (!is_bool)\n+\t\t\treturn xstrdup(value);\n+\t\telse\n+\t\t\treturn xstrdup(v ? \"true\" : \"false\");\n+\t}\n \tif (type == TYPE_COLOR) {\n \t\tchar v[COLOR_MAXLEN];\n \t\tif (git_config_color(v, key, value))\ndiff --git a/config.c b/config.c\nindex 8db9c77098..4c6c06d10b 100644\n--- a/config.c\n+++ b/config.c\n@@ -1100,6 +1100,20 @@ int git_config_bool_or_int(const char *name, const char *value, int *is_bool)\n \treturn git_config_int(name, value);\n }\n \n+int git_config_bool_or_str(const char **dest, const char *name, const char *value, int *is_bool)\n+{\n+\tint v = git_parse_maybe_bool_text(value);\n+\tif (0 <= v) {\n+\t\t*is_bool = 1;\n+\t\treturn v;\n+\t}\n+\t*is_bool = 0;\n+\tif (dest != NULL)\n+\t  return git_config_string(dest, name, value);\n+\telse\n+\t  return 0;\n+}\n+\n int git_config_bool(const char *name, const char *value)\n {\n \tint discard;\ndiff --git a/config.h b/config.h\nindex 060874488f..175b88d9c5 100644\n--- a/config.h\n+++ b/config.h\n@@ -217,6 +217,13 @@ ssize_t git_config_ssize_t(const char *, const char *);\n  */\n int git_config_bool_or_int(const char *, const char *, int *);\n \n+/**\n+ * Same as `git_config_bool`, except that `is_bool` flag is unset, then if\n+ * `dest` parameter is non-NULL, it allocates and copies the value string\n+ * into the `dest`, if `dest` is NULL and `is_bool` flag is unset it return 0.\n+ */\n+int git_config_bool_or_str(const char **, const char *, const char *, int *);\n+\n /**\n  * Parse a string into a boolean value, respecting keywords like \"true\" and\n  * \"false\". Integer values are converted into true/false values (when they\ndiff --git a/mergetools/meld b/mergetools/meld\nindex 7a08470f88..bc2ea894d7 100644\n--- a/mergetools/meld\n+++ b/mergetools/meld\n@@ -3,34 +3,83 @@ diff_cmd () {\n }\n \n merge_cmd () {\n-\tif test -z \"${meld_has_output_option:+set}\"\n+\tcheck_meld_for_features\n+\n+\toption_auto_merge=\n+\tif test \"$meld_use_auto_merge_option\" = true\n \tthen\n-\t\tcheck_meld_for_output_version\n+\t\toption_auto_merge=\"--auto-merge\"\n \tfi\n \n \tif test \"$meld_has_output_option\" = true\n \tthen\n-\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n+\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \telse\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \tfi\n }\n \n-# Check whether we should use 'meld --output <file>'\n-check_meld_for_output_version () {\n-\tmeld_path=\"$(git config mergetool.meld.path)\"\n-\tmeld_path=\"${meld_path:-meld}\"\n+# Get meld help message\n+init_meld_help_msg () {\n+\tif test -z \"$meld_help_msg\"\n+\tthen\n+\t\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n+\t\tmeld_help_msg=$(\"$meld_path\" --help 2>&1)\n+\tfi\n+}\n \n-\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+# Check the features and set flags\n+check_meld_for_features () {\n+\t# Check whether we should use 'meld --output <file>'\n+\tif test -z \"$meld_has_output_option\"\n \tthen\n-\t\t: use configured value\n-\telif \"$meld_path\" --help 2>&1 |\n-\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n+\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+\t\tcase \"$meld_has_output_option\" in\n+\t\ttrue|false)\n+\t\t\t: use configured value\n+\t\t\t;;\n+\t\t*)\n+\t\t\t: empty or invalid configured value, detecting \"--output\" automatically\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--output=\"*|*'[OPTION...]'*)\n+\t\t\t\t# All version that has [OPTION...] supports --output\n+\t\t\t\tmeld_has_output_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_has_output_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\tesac\n+\tfi\n+\t# Check whether we should use 'meld --auto-merge ...'\n+\tif test -z \"$meld_use_auto_merge_option\"\n \tthen\n-\t\t: old ones mention --output and new ones just say OPTION...\n-\t\tmeld_has_output_option=true\n-\telse\n-\t\tmeld_has_output_option=false\n+\t\tmeld_use_auto_merge_option=$(\n+\t\t\tgit config --bool-or-str mergetool.meld.useAutoMerge)\n+\t\tcase \"$meld_use_auto_merge_option\" in\n+\t\ttrue|false)\n+\t\t\t: use well formatted boolean value\n+\t\t\t;;\n+\t\tauto)\n+\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--auto-merge\"*|*'[OPTION...]'*)\n+\t\t\t\tmeld_use_auto_merge_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_use_auto_merge_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\t*)\n+\t\t\tmeld_use_auto_merge_option=false\n+\t\t\t;;\n+\t\tesac\n \tfi\n }\n\nbase-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n-- \ngitgitgadget\n"},{"id":"401412","messageId":"003701d65855$c1874320$4495c960$@zoom.us","threadId":"53430","inReplyTo":"261a01d655a0$71077210$53165630$@zoom.us","subject":"RE: [PATCH v13] Support auto-merge for meld to follow the vim-diff behavior","fromName":"","fromEmail":"lin.sun@zoom.us","sentAt":"2020-07-12T14:07:13Z","receivedAt":"2020-07-12T14:07:18Z","isPatch":true,"sender":{"key":"lin.sun@zoom.us","avatar":null},"body":"Hi Junio,\n\nI had add a new c function ` git_config_bool_or_str()` to support get the \nconfigured value for true/false/auto with git. It will make the `mergetool/meld`\nonly calling `git config` once for getting the `useAutoMerge`.\n\nPlease review the [PATH v16], thanks.\nhttps://lore.kernel.org/git/pull.781.v16.git.git.1594544903477.gitgitgadget@gmail.com\n\nRegards\nLin\n\n"},{"id":"401417","messageId":"xmqqzh84pq3l.fsf@gitster.c.googlers.com","threadId":"53430","inReplyTo":"pull.781.v16.git.git.1594544903477.gitgitgadget@gmail.com","subject":"Re: [PATCH v16] Support auto-merge for meld to follow the vim-diff behavior","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-07-12T18:04:14Z","receivedAt":"2020-07-12T18:04:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"sunlin via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Lin Sun <lin.sun@zoom.us>\n>\n> Make the mergetool used with \"meld\" backend behave similarly to \"vimdiff\" by\n> telling it to auto-merge non-conflicting parts and highlight the conflicting\n> parts when `mergetool.meld.useAutoMerge` is configured with `true`, or `auto`\n> for detecting the `--auto-merge` option automatically.\n>\n> Helped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\n> Helped-by: David Aguilar <davvid@gmail.com>\n> Signed-off-by: Lin Sun <lin.sun@zoom.us>\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n>     Enable auto-merge for meld to follow the vimdiff beharior\n>     \n>     Hi, the mergetool \"meld\" does NOT merge the no-conflict changes, while\n>     the mergetool \"vimdiff\" will merge the no-conflict changes and highlight\n>     the conflict parts. This patch will make the mergetool \"meld\" similar to\n>     \"vimdiff\", auto-merge the no-conflict changes, highlight conflict parts.\n>\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-781%2Fsunlin7%2Fmaster-v16\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-781/sunlin7/master-v16\n> Pull-Request: https://github.com/git/git/pull/781\n>\n> Range-diff vs v15:\n>\n>  1:  02d849784f ! 1:  d235a576b4 Support auto-merge for meld to follow the vim-diff behavior\n>      @@ mergetools/meld: diff_cmd () {\n>       -\telse\n>       -\t\tmeld_has_output_option=false\n>       +\t\tmeld_use_auto_merge_option=$(\n>      -+\t\t\tgit --bool-or-str config mergetool.meld.useAutoMerge)\n>      ++\t\t\tgit config --bool-or-str mergetool.meld.useAutoMerge)\n\nIt is quite clear in this hunk that that the previous one was not\neven proofread before sending X-<.\n\n> +\t\t} else if (type == TYPE_BOOL_OR_STR) {\n> +\t\t\tint is_bool, v;\n> +\t\t\tv = git_config_bool_or_str(NULL, key_, value_, &is_bool);\n> +\t\t\tif (is_bool)\n> +\t\t\t\tstrbuf_addstr(buf, v ? \"true\" : \"false\");\n> +\t\t\telse\n> +\t\t\t\tstrbuf_addstr(buf, value_);\n>  \t\t} else if (type == TYPE_PATH) {\n>  \t\t\tconst char *v;\n>  \t\t\tif (git_config_pathname(&v, key_, value_) < 0)\n> @@ -411,6 +422,14 @@ static char *normalize_value(const char *key, const char *value)\n>  \t\telse\n>  \t\t\treturn xstrdup(v ? \"true\" : \"false\");\n>  \t}\n> +\tif (type == TYPE_BOOL_OR_STR) {\n> +\t\tint is_bool, v;\n> +\t\tv = git_config_bool_or_str(NULL, key, value, &is_bool);\n> +\t\tif (!is_bool)\n> +\t\t\treturn xstrdup(value);\n> +\t\telse\n> +\t\t\treturn xstrdup(v ? \"true\" : \"false\");\n> +\t}\n\nThat's unfortunate that we need almost identical code duplicated\nhere and above.  It probably is a tad larger than what we typcally\ncall #leftoverbits, so please ignore it for now.\n\n> diff --git a/config.c b/config.c\n> index 8db9c77098..4c6c06d10b 100644\n> --- a/config.c\n> +++ b/config.c\n> @@ -1100,6 +1100,20 @@ int git_config_bool_or_int(const char *name, const char *value, int *is_bool)\n>  \treturn git_config_int(name, value);\n>  }\n>  \n> +int git_config_bool_or_str(const char **dest, const char *name, const char *value, int *is_bool)\n> +{\n> +\tint v = git_parse_maybe_bool_text(value);\n> +\tif (0 <= v) {\n> +\t\t*is_bool = 1;\n> +\t\treturn v;\n> +\t}\n> +\t*is_bool = 0;\n> +\tif (dest != NULL)\n> +\t  return git_config_string(dest, name, value);\n> +\telse\n> +\t  return 0;\n> +}\n\nWrong indentation.\n\nI do not think this is a good interface at all, from at least three\npoints.\n\n - What happens when the value is set to \"2\"?  git_config_bool()\n   would say, because it calls git_config_bool_or_int() and learns\n   that the value is an integer 2 and uses !! operator on it to\n   normalize it to 1, we judge it as \"true\".  Your implementation\n   says it is not a bool and instead it is a string \"2\".  When\n   telling a boolean and an integer apart, saying 2 is not a bool\n   makes sense, but given that \"interpret this value as boolean\"\n   logic in git_config_bool() says \"2\" is a true, the logic to tell\n   a boolean and a string apart probably should say that the user\n   who wrote \"2\" there meant true, i.e. boolean.\n\n - What's the returned value from this function and how can the\n   caller sensibly use it?  If it happened to be (narrowly defined)\n   bool, the returned value is 0 for false and 1 for true.\n   Otherwise, the caller gets 0 if it forgets to pass dest, or 0 if\n   value successfully gets returned as a string, or -1 upon an\n   error.  Hence it is impossible for the caller to use\n\n\tif (git_config_bool_or_str(...)) {\n\t\t... do one thing ...\n\t} else {\n\t\t... do something else ...\n\t}\n\n - There is no point to pass dest to this function.  If it is not\n   bool, then the caller can do strdup() the value.\n\n> diff --git a/config.h b/config.h\n> index 060874488f..175b88d9c5 100644\n> --- a/config.h\n> +++ b/config.h\n> @@ -217,6 +217,13 @@ ssize_t git_config_ssize_t(const char *, const char *);\n>   */\n>  int git_config_bool_or_int(const char *, const char *, int *);\n>  \n> +/**\n> + * Same as `git_config_bool`, except that `is_bool` flag is unset, then if\n> + * `dest` parameter is non-NULL, it allocates and copies the value string\n> + * into the `dest`, if `dest` is NULL and `is_bool` flag is unset it return 0.\n> + */\n\nis_bool is not an \"in-parameter\" flag but a pointer to point at\nwhere the result is stored, so the above description does not make\nmuch sense.  I suspect, from the actual implementation, that you\nwanted to say\n\n    Parse \"value\" to see if it is a boolean, and if so set *is_bool\n    to true and leave *dest untouched.  If it is not a boolean, set\n    *is_bool to false and assign a copy of value to *dest.\n\nBut again, I do not think this function is designed right, so let's\nnot spend any more time polishing what you wrote for now.\n\nI would expect something like this in builtin/config.c would be\nsufficient:\n\n\tif (type == TYPE_BOOL_OR_STRING) {\n\t\tint v = git_parse_maybe_bool(value);\n\t\tif (v < 0)\n\t\t\treturn xstrdup(value);\n\t\telse\n\t\t\treturn xstrdup(v ? \"true\" : \"false\");\n\t}\n\ni.e. we do not need a new helper in the lower level of the API stack.\n\n> +\t\tmeld_use_auto_merge_option=$(\n> +\t\t\tgit config --bool-or-str mergetool.meld.useAutoMerge)\n\nIf the body is made on a separate line for readability, doing it more\nlike so would be even more readable:\n\n\t\tmeld_use_auto_merge_option=$(\n\t\t\tgit config --bool-or-str mergetool.meld.useAutoMerge\n\t\t)\n\n> +\t\tcase \"$meld_use_auto_merge_option\" in\n> +\t\ttrue|false)\n> +\t\t\t: use well formatted boolean value\n> +\t\t\t;;\n> +\t\tauto)\n> +\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n> +\t\t\tinit_meld_help_msg\n> +\n> +\t\t\tcase \"$meld_help_msg\" in\n> +\t\t\t*\"--auto-merge\"*|*'[OPTION...]'*)\n> +\t\t\t\tmeld_use_auto_merge_option=true\n> +\t\t\t\t;;\n> +\t\t\t*)\n> +\t\t\t\tmeld_use_auto_merge_option=false\n> +\t\t\t\t;;\n> +\t\t\tesac\n> +\t\t\t;;\n> +\t\t*)\n> +\t\t\tmeld_use_auto_merge_option=false\n\nNow that the --bool-or-string would be silent, you have to give an\nerror message yourself here, no?  Have you hand-tested the result of\napplying your patch to see if all the cases we care about (i.e.\nvarious scenarios we raised and thought together how the code should\nreact to the situation during the review discussion so far)?\n\nWe are not in a hurry, and we will not be paying too much attention\non topics that are not yet in 'next' until the upcoming release is\ndone anyway, so take your time to try polishing before sending\nanything out.\n\nThanks.\n"},{"id":"401427","messageId":"002701d658a3$f09ca6c0$d1d5f440$@zoom.us","threadId":"53430","inReplyTo":"xmqqzh84pq3l.fsf@gitster.c.googlers.com","subject":"RE: [PATCH v16] Support auto-merge for meld to follow the vim-diff behavior","fromName":"","fromEmail":"lin.sun@zoom.us","sentAt":"2020-07-12T23:26:54Z","receivedAt":"2020-07-12T23:27:28Z","isPatch":true,"sender":{"key":"lin.sun@zoom.us","avatar":null},"body":"Hi Junio,\n\nApologize for the [PATCH v16] which is not well thoughtful, and I totally agree that we will not paying too much attention before upcoming release. \nI'll rollback changes to preview one,  thank you so much.\n\nBest Regards\nLin\n\n"},{"id":"401428","messageId":"pull.781.v17.git.git.1594596738929.gitgitgadget@gmail.com","threadId":"53430","inReplyTo":"pull.781.v16.git.git.1594544903477.gitgitgadget@gmail.com","subject":"[PATCH v17] Support auto-merge for meld to follow the vim-diff behavior","fromName":"sunlin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-07-12T23:32:18Z","receivedAt":"2020-07-12T23:32:23Z","isPatch":true,"sender":{"key":"name:sunlin","avatar":null},"body":"From: Lin Sun <lin.sun@zoom.us>\n\nMake the mergetool used with \"meld\" backend behave similarly to \"vimdiff\" by\ntelling it to auto-merge non-conflicting parts and highlight the conflicting\nparts when `mergetool.meld.useAutoMerge` is configured with `true`, or `auto`\nfor detecting the `--auto-merge` option automatically.\n\nHelped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\nHelped-by: David Aguilar <davvid@gmail.com>\nSigned-off-by: Lin Sun <lin.sun@zoom.us>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n    Enable auto-merge for meld to follow the vimdiff beharior\n    \n    Hi, the mergetool \"meld\" does NOT merge the no-conflict changes, while\n    the mergetool \"vimdiff\" will merge the no-conflict changes and highlight\n    the conflict parts. This patch will make the mergetool \"meld\" similar to\n    \"vimdiff\", auto-merge the no-conflict changes, highlight conflict parts.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-781%2Fsunlin7%2Fmaster-v17\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-781/sunlin7/master-v17\nPull-Request: https://github.com/git/git/pull/781\n\nRange-diff vs v16:\n\n 1:  d235a576b4 ! 1:  ce4e4cbfc0 Support auto-merge for meld to follow the vim-diff behavior\n     @@ Documentation/config/mergetool.txt: mergetool.meld.hasOutput::\n       \tAfter performing a merge, the original file with conflict markers\n       \tcan be saved as a file with a `.orig` extension.  If this variable\n      \n     - ## builtin/config.c ##\n     -@@ builtin/config.c: static int show_scope;\n     - #define TYPE_PATH\t\t4\n     - #define TYPE_EXPIRY_DATE\t5\n     - #define TYPE_COLOR\t\t6\n     -+#define TYPE_BOOL_OR_STR        7\n     - \n     - #define OPT_CALLBACK_VALUE(s, l, v, h, i) \\\n     - \t{ OPTION_CALLBACK, (s), (l), (v), NULL, (h), PARSE_OPT_NOARG | \\\n     -@@ builtin/config.c: static int option_parse_type(const struct option *opt, const char *arg,\n     - \t\t\tnew_type = TYPE_INT;\n     - \t\telse if (!strcmp(arg, \"bool-or-int\"))\n     - \t\t\tnew_type = TYPE_BOOL_OR_INT;\n     -+\t\telse if (!strcmp(arg, \"bool-or-str\"))\n     -+\t\t\tnew_type = TYPE_BOOL_OR_STR;\n     - \t\telse if (!strcmp(arg, \"path\"))\n     - \t\t\tnew_type = TYPE_PATH;\n     - \t\telse if (!strcmp(arg, \"expiry-date\"))\n     -@@ builtin/config.c: static struct option builtin_config_options[] = {\n     - \tOPT_CALLBACK_VALUE(0, \"bool\", &type, N_(\"value is \\\"true\\\" or \\\"false\\\"\"), TYPE_BOOL),\n     - \tOPT_CALLBACK_VALUE(0, \"int\", &type, N_(\"value is decimal number\"), TYPE_INT),\n     - \tOPT_CALLBACK_VALUE(0, \"bool-or-int\", &type, N_(\"value is --bool or --int\"), TYPE_BOOL_OR_INT),\n     -+\tOPT_CALLBACK_VALUE(0, \"bool-or-str\", &type, N_(\"value is --bool or string\"), TYPE_BOOL_OR_STR),\n     - \tOPT_CALLBACK_VALUE(0, \"path\", &type, N_(\"value is a path (file or directory name)\"), TYPE_PATH),\n     - \tOPT_CALLBACK_VALUE(0, \"expiry-date\", &type, N_(\"value is an expiry date\"), TYPE_EXPIRY_DATE),\n     - \tOPT_GROUP(N_(\"Other\")),\n     -@@ builtin/config.c: static int format_config(struct strbuf *buf, const char *key_, const char *value\n     - \t\t\t\tstrbuf_addstr(buf, v ? \"true\" : \"false\");\n     - \t\t\telse\n     - \t\t\t\tstrbuf_addf(buf, \"%d\", v);\n     -+\t\t} else if (type == TYPE_BOOL_OR_STR) {\n     -+\t\t\tint is_bool, v;\n     -+\t\t\tv = git_config_bool_or_str(NULL, key_, value_, &is_bool);\n     -+\t\t\tif (is_bool)\n     -+\t\t\t\tstrbuf_addstr(buf, v ? \"true\" : \"false\");\n     -+\t\t\telse\n     -+\t\t\t\tstrbuf_addstr(buf, value_);\n     - \t\t} else if (type == TYPE_PATH) {\n     - \t\t\tconst char *v;\n     - \t\t\tif (git_config_pathname(&v, key_, value_) < 0)\n     -@@ builtin/config.c: static char *normalize_value(const char *key, const char *value)\n     - \t\telse\n     - \t\t\treturn xstrdup(v ? \"true\" : \"false\");\n     - \t}\n     -+\tif (type == TYPE_BOOL_OR_STR) {\n     -+\t\tint is_bool, v;\n     -+\t\tv = git_config_bool_or_str(NULL, key, value, &is_bool);\n     -+\t\tif (!is_bool)\n     -+\t\t\treturn xstrdup(value);\n     -+\t\telse\n     -+\t\t\treturn xstrdup(v ? \"true\" : \"false\");\n     -+\t}\n     - \tif (type == TYPE_COLOR) {\n     - \t\tchar v[COLOR_MAXLEN];\n     - \t\tif (git_config_color(v, key, value))\n     -\n     - ## config.c ##\n     -@@ config.c: int git_config_bool_or_int(const char *name, const char *value, int *is_bool)\n     - \treturn git_config_int(name, value);\n     - }\n     - \n     -+int git_config_bool_or_str(const char **dest, const char *name, const char *value, int *is_bool)\n     -+{\n     -+\tint v = git_parse_maybe_bool_text(value);\n     -+\tif (0 <= v) {\n     -+\t\t*is_bool = 1;\n     -+\t\treturn v;\n     -+\t}\n     -+\t*is_bool = 0;\n     -+\tif (dest != NULL)\n     -+\t  return git_config_string(dest, name, value);\n     -+\telse\n     -+\t  return 0;\n     -+}\n     -+\n     - int git_config_bool(const char *name, const char *value)\n     - {\n     - \tint discard;\n     -\n     - ## config.h ##\n     -@@ config.h: ssize_t git_config_ssize_t(const char *, const char *);\n     -  */\n     - int git_config_bool_or_int(const char *, const char *, int *);\n     - \n     -+/**\n     -+ * Same as `git_config_bool`, except that `is_bool` flag is unset, then if\n     -+ * `dest` parameter is non-NULL, it allocates and copies the value string\n     -+ * into the `dest`, if `dest` is NULL and `is_bool` flag is unset it return 0.\n     -+ */\n     -+int git_config_bool_or_str(const char **, const char *, const char *, int *);\n     -+\n     - /**\n     -  * Parse a string into a boolean value, respecting keywords like \"true\" and\n     -  * \"false\". Integer values are converted into true/false values (when they\n     -\n       ## mergetools/meld ##\n      @@ mergetools/meld: diff_cmd () {\n       }\n     @@ mergetools/meld: diff_cmd () {\n      -\t\tmeld_has_output_option=true\n      -\telse\n      -\t\tmeld_has_output_option=false\n     -+\t\tmeld_use_auto_merge_option=$(\n     -+\t\t\tgit config --bool-or-str mergetool.meld.useAutoMerge)\n     ++\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n      +\t\tcase \"$meld_use_auto_merge_option\" in\n      +\t\ttrue|false)\n      +\t\t\t: use well formatted boolean value\n     @@ mergetools/meld: diff_cmd () {\n      +\t\t\tesac\n      +\t\t\t;;\n      +\t\t*)\n     -+\t\t\tmeld_use_auto_merge_option=false\n     ++\t\t\t# try other boolean value with git\n     ++\t\t\tif meld_use_auto_merge_option=$(\n     ++\t\t\t\t git config --bool mergetool.meld.useAutoMerge)\n     ++\t\t\tthen\n     ++\t\t\t\t: use normalized boolean value\n     ++\t\t\telse\n     ++\t\t\t\tmeld_use_auto_merge_option=false\n     ++\t\t\tfi\n      +\t\t\t;;\n      +\t\tesac\n       \tfi\n\n\n Documentation/config/mergetool.txt | 10 ++++\n mergetools/meld                    | 87 ++++++++++++++++++++++++------\n 2 files changed, 81 insertions(+), 16 deletions(-)\n\ndiff --git a/Documentation/config/mergetool.txt b/Documentation/config/mergetool.txt\nindex 09ed31dbfa..16a27443a3 100644\n--- a/Documentation/config/mergetool.txt\n+++ b/Documentation/config/mergetool.txt\n@@ -30,6 +30,16 @@ mergetool.meld.hasOutput::\n \tto `true` tells Git to unconditionally use the `--output` option,\n \tand `false` avoids using `--output`.\n \n+mergetool.meld.useAutoMerge::\n+\tWhen the `--auto-merge` is given, meld will merge all non-conflicting\n+\tparts automatically, highlight the conflicting parts and wait for\n+\tuser decision.  Setting `mergetool.meld.useAutoMerge` to `true` tells\n+\tGit to unconditionally use the `--auto-merge` option with `meld`.\n+\tSetting this value to `auto` makes git detect whether `--auto-merge`\n+\tis supported and will only use `--auto-merge` when available.  A\n+\tvalue of `false` avoids using `--auto-merge` altogether, and is the\n+\tdefault value.\n+\n mergetool.keepBackup::\n \tAfter performing a merge, the original file with conflict markers\n \tcan be saved as a file with a `.orig` extension.  If this variable\ndiff --git a/mergetools/meld b/mergetools/meld\nindex 7a08470f88..d95b4ee630 100644\n--- a/mergetools/meld\n+++ b/mergetools/meld\n@@ -3,34 +3,89 @@ diff_cmd () {\n }\n \n merge_cmd () {\n-\tif test -z \"${meld_has_output_option:+set}\"\n+\tcheck_meld_for_features\n+\n+\toption_auto_merge=\n+\tif test \"$meld_use_auto_merge_option\" = true\n \tthen\n-\t\tcheck_meld_for_output_version\n+\t\toption_auto_merge=\"--auto-merge\"\n \tfi\n \n \tif test \"$meld_has_output_option\" = true\n \tthen\n-\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n+\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \telse\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \tfi\n }\n \n-# Check whether we should use 'meld --output <file>'\n-check_meld_for_output_version () {\n-\tmeld_path=\"$(git config mergetool.meld.path)\"\n-\tmeld_path=\"${meld_path:-meld}\"\n+# Get meld help message\n+init_meld_help_msg () {\n+\tif test -z \"$meld_help_msg\"\n+\tthen\n+\t\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n+\t\tmeld_help_msg=$(\"$meld_path\" --help 2>&1)\n+\tfi\n+}\n \n-\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+# Check the features and set flags\n+check_meld_for_features () {\n+\t# Check whether we should use 'meld --output <file>'\n+\tif test -z \"$meld_has_output_option\"\n \tthen\n-\t\t: use configured value\n-\telif \"$meld_path\" --help 2>&1 |\n-\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n+\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+\t\tcase \"$meld_has_output_option\" in\n+\t\ttrue|false)\n+\t\t\t: use configured value\n+\t\t\t;;\n+\t\t*)\n+\t\t\t: empty or invalid configured value, detecting \"--output\" automatically\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--output=\"*|*'[OPTION...]'*)\n+\t\t\t\t# All version that has [OPTION...] supports --output\n+\t\t\t\tmeld_has_output_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_has_output_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\tesac\n+\tfi\n+\t# Check whether we should use 'meld --auto-merge ...'\n+\tif test -z \"$meld_use_auto_merge_option\"\n \tthen\n-\t\t: old ones mention --output and new ones just say OPTION...\n-\t\tmeld_has_output_option=true\n-\telse\n-\t\tmeld_has_output_option=false\n+\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n+\t\tcase \"$meld_use_auto_merge_option\" in\n+\t\ttrue|false)\n+\t\t\t: use well formatted boolean value\n+\t\t\t;;\n+\t\tauto)\n+\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--auto-merge\"*|*'[OPTION...]'*)\n+\t\t\t\tmeld_use_auto_merge_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_use_auto_merge_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\t*)\n+\t\t\t# try other boolean value with git\n+\t\t\tif meld_use_auto_merge_option=$(\n+\t\t\t\t git config --bool mergetool.meld.useAutoMerge)\n+\t\t\tthen\n+\t\t\t\t: use normalized boolean value\n+\t\t\telse\n+\t\t\t\tmeld_use_auto_merge_option=false\n+\t\t\tfi\n+\t\t\t;;\n+\t\tesac\n \tfi\n }\n\nbase-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17\n-- \ngitgitgadget\n"},{"id":"401429","messageId":"002801d658a5$80a651c0$81f2f540$@zoom.us","threadId":"53430","inReplyTo":"003701d65855$c1874320$4495c960$@zoom.us","subject":"RE: [PATCH v13] Support auto-merge for meld to follow the vim-diff behavior","fromName":"","fromEmail":"lin.sun@zoom.us","sentAt":"2020-07-12T23:38:06Z","receivedAt":"2020-07-12T23:38:09Z","isPatch":true,"sender":{"key":"lin.sun@zoom.us","avatar":null},"body":"Hi Junio,\n\nI had rollback the changes, which is submit as [PATCH v17], it's same as [PATCH v14].\n\nYou can just ignore it. Thanks\n\nhttps://lore.kernel.org/git/pull.781.v17.git.git.1594596738929.gitgitgadget@gmail.com\nhttps://lore.kernel.org/git/pull.781.v14.git.git.1594268906195.gitgitgadget@gmail.com\n\nRegards\nLin\n\n"},{"id":"401473","messageId":"xmqq5zasov21.fsf@gitster.c.googlers.com","threadId":"53430","inReplyTo":"xmqqzh84pq3l.fsf@gitster.c.googlers.com","subject":"Re: [PATCH v16] Support auto-merge for meld to follow the vim-diff behavior","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-07-13T05:14:46Z","receivedAt":"2020-07-13T05:14:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> ...\n> Now that the --bool-or-string would be silent, you have to give an\n> error message yourself here, no?  Have you hand-tested the result of\n> applying your patch to see if all the cases we care about (i.e.\n> various scenarios we raised and thought together how the code should\n> react to the situation during the review discussion so far)?\n>\n> We are not in a hurry, and we will not be paying too much attention\n> on topics that are not yet in 'next' until the upcoming release is\n> done anyway, so take your time to try polishing before sending\n> anything out.\n\nJust for fun, I've queued the following on top of v16 and merged the\nresult to 'seen'.\n\nAs this adds a new feature to \"git config\", it also needs updates to\nDocumentation/git-config.txt and tests for the feature, and it\nprobably makes sense to make it a two-patch series.  Everything\nrelated to the \"git config\" enhancement as 1/2, and change to\nmergetools/meld as 2/2.\n\n builtin/config.c | 16 +++++++---------\n config.c         | 14 --------------\n config.h         |  7 -------\n mergetools/meld  | 16 ++++++++++------\n 4 files changed, 17 insertions(+), 36 deletions(-)\n\ndiff --git a/builtin/config.c b/builtin/config.c\nindex 6f2ddadc80..7891e070a4 100644\n--- a/builtin/config.c\n+++ b/builtin/config.c\n@@ -65,7 +65,7 @@ static int show_scope;\n #define TYPE_PATH\t\t4\n #define TYPE_EXPIRY_DATE\t5\n #define TYPE_COLOR\t\t6\n-#define TYPE_BOOL_OR_STR        7\n+#define TYPE_BOOL_OR_STR\t7\n \n #define OPT_CALLBACK_VALUE(s, l, v, h, i) \\\n \t{ OPTION_CALLBACK, (s), (l), (v), NULL, (h), PARSE_OPT_NOARG | \\\n@@ -255,12 +255,11 @@ static int format_config(struct strbuf *buf, const char *key_, const char *value\n \t\t\telse\n \t\t\t\tstrbuf_addf(buf, \"%d\", v);\n \t\t} else if (type == TYPE_BOOL_OR_STR) {\n-\t\t\tint is_bool, v;\n-\t\t\tv = git_config_bool_or_str(NULL, key_, value_, &is_bool);\n-\t\t\tif (is_bool)\n-\t\t\t\tstrbuf_addstr(buf, v ? \"true\" : \"false\");\n-\t\t\telse\n+\t\t\tint v = git_parse_maybe_bool(value_);\n+\t\t\tif (v < 0)\n \t\t\t\tstrbuf_addstr(buf, value_);\n+\t\t\telse\n+\t\t\t\tstrbuf_addstr(buf, v ? \"true\" : \"false\");\n \t\t} else if (type == TYPE_PATH) {\n \t\t\tconst char *v;\n \t\t\tif (git_config_pathname(&v, key_, value_) < 0)\n@@ -423,9 +422,8 @@ static char *normalize_value(const char *key, const char *value)\n \t\t\treturn xstrdup(v ? \"true\" : \"false\");\n \t}\n \tif (type == TYPE_BOOL_OR_STR) {\n-\t\tint is_bool, v;\n-\t\tv = git_config_bool_or_str(NULL, key, value, &is_bool);\n-\t\tif (!is_bool)\n+\t\tint v = git_parse_maybe_bool(value);\n+\t\tif (v < 0)\n \t\t\treturn xstrdup(value);\n \t\telse\n \t\t\treturn xstrdup(v ? \"true\" : \"false\");\ndiff --git a/config.c b/config.c\nindex 4c6c06d10b..8db9c77098 100644\n--- a/config.c\n+++ b/config.c\n@@ -1100,20 +1100,6 @@ int git_config_bool_or_int(const char *name, const char *value, int *is_bool)\n \treturn git_config_int(name, value);\n }\n \n-int git_config_bool_or_str(const char **dest, const char *name, const char *value, int *is_bool)\n-{\n-\tint v = git_parse_maybe_bool_text(value);\n-\tif (0 <= v) {\n-\t\t*is_bool = 1;\n-\t\treturn v;\n-\t}\n-\t*is_bool = 0;\n-\tif (dest != NULL)\n-\t  return git_config_string(dest, name, value);\n-\telse\n-\t  return 0;\n-}\n-\n int git_config_bool(const char *name, const char *value)\n {\n \tint discard;\ndiff --git a/config.h b/config.h\nindex 175b88d9c5..060874488f 100644\n--- a/config.h\n+++ b/config.h\n@@ -217,13 +217,6 @@ ssize_t git_config_ssize_t(const char *, const char *);\n  */\n int git_config_bool_or_int(const char *, const char *, int *);\n \n-/**\n- * Same as `git_config_bool`, except that `is_bool` flag is unset, then if\n- * `dest` parameter is non-NULL, it allocates and copies the value string\n- * into the `dest`, if `dest` is NULL and `is_bool` flag is unset it return 0.\n- */\n-int git_config_bool_or_str(const char **, const char *, const char *, int *);\n-\n /**\n  * Parse a string into a boolean value, respecting keywords like \"true\" and\n  * \"false\". Integer values are converted into true/false values (when they\ndiff --git a/mergetools/meld b/mergetools/meld\nindex bc2ea894d7..aab4ebb935 100644\n--- a/mergetools/meld\n+++ b/mergetools/meld\n@@ -36,7 +36,7 @@ check_meld_for_features () {\n \tthen\n \t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n \t\tcase \"$meld_has_output_option\" in\n-\t\ttrue|false)\n+\t\ttrue | false)\n \t\t\t: use configured value\n \t\t\t;;\n \t\t*)\n@@ -44,7 +44,7 @@ check_meld_for_features () {\n \t\t\tinit_meld_help_msg\n \n \t\t\tcase \"$meld_help_msg\" in\n-\t\t\t*\"--output=\"*|*'[OPTION...]'*)\n+\t\t\t*\"--output=\"* | *'[OPTION...]'*)\n \t\t\t\t# All version that has [OPTION...] supports --output\n \t\t\t\tmeld_has_output_option=true\n \t\t\t\t;;\n@@ -59,9 +59,10 @@ check_meld_for_features () {\n \tif test -z \"$meld_use_auto_merge_option\"\n \tthen\n \t\tmeld_use_auto_merge_option=$(\n-\t\t\tgit config --bool-or-str mergetool.meld.useAutoMerge)\n+\t\t\tgit config --bool-or-str mergetool.meld.useAutoMerge\n+\t\t)\n \t\tcase \"$meld_use_auto_merge_option\" in\n-\t\ttrue|false)\n+\t\ttrue | false)\n \t\t\t: use well formatted boolean value\n \t\t\t;;\n \t\tauto)\n@@ -69,7 +70,7 @@ check_meld_for_features () {\n \t\t\tinit_meld_help_msg\n \n \t\t\tcase \"$meld_help_msg\" in\n-\t\t\t*\"--auto-merge\"*|*'[OPTION...]'*)\n+\t\t\t*\"--auto-merge\"* | *'[OPTION...]'*)\n \t\t\t\tmeld_use_auto_merge_option=true\n \t\t\t\t;;\n \t\t\t*)\n@@ -77,9 +78,12 @@ check_meld_for_features () {\n \t\t\t\t;;\n \t\t\tesac\n \t\t\t;;\n-\t\t*)\n+\t\t\"\")\n \t\t\tmeld_use_auto_merge_option=false\n \t\t\t;;\n+\t\t*)\n+\t\t\tdie \"unknown mergetool.meld.useAutoMerge: $meld_use_auto_merge_option\"\n+\t\t\t;;\n \t\tesac\n \tfi\n }\n-- \n2.28.0-rc0\n\n"},{"id":"401475","messageId":"16ebc01d658e2$ffbce130$ff36a390$@zoom.us","threadId":"53430","inReplyTo":"xmqq5zasov21.fsf@gitster.c.googlers.com","subject":"RE: [PATCH v16] Support auto-merge for meld to follow the vim-diff behavior","fromName":"","fromEmail":"lin.sun@zoom.us","sentAt":"2020-07-13T06:58:19Z","receivedAt":"2020-07-13T06:58:27Z","isPatch":true,"sender":{"key":"lin.sun@zoom.us","avatar":null},"body":"Hi Junio,\n\n> As this adds a new feature to \"git config\", it also needs updates to Documentation/git-config.txt and tests for the feature, and it probably makes sense to make it a two-patch series.  Everything related to the \"git config\" enhancement as 1/2, and change to mergetools/meld as 2/2.\nThank you for your comments, these are key points for adding new feature into git.\nI'll try my best to make new pull-requests for option `--bool-or-string` after current feature is applied upstream. \n\nRegards\nLin\n\n"},{"id":"401981","messageId":"xmqqv9idn2yr.fsf@gitster.c.googlers.com","threadId":"53430","inReplyTo":"pull.781.v17.git.git.1594596738929.gitgitgadget@gmail.com","subject":"Re: [PATCH v17] Support auto-merge for meld to follow the vim-diff behavior","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-07-24T00:58:36Z","receivedAt":"2020-07-24T00:58:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"sunlin via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Lin Sun <lin.sun@zoom.us>\n>\n> Make the mergetool used with \"meld\" backend behave similarly to \"vimdiff\" by\n> telling it to auto-merge non-conflicting parts and highlight the conflicting\n> parts when `mergetool.meld.useAutoMerge` is configured with `true`, or `auto`\n> for detecting the `--auto-merge` option automatically.\n>\n> Helped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\n> Helped-by: David Aguilar <davvid@gmail.com>\n> Signed-off-by: Lin Sun <lin.sun@zoom.us>\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n>     Enable auto-merge for meld to follow the vimdiff beharior\n>     \n>     Hi, the mergetool \"meld\" does NOT merge the no-conflict changes, while\n>     the mergetool \"vimdiff\" will merge the no-conflict changes and highlight\n>     the conflict parts. This patch will make the mergetool \"meld\" similar to\n>     \"vimdiff\", auto-merge the no-conflict changes, highlight conflict parts.\n\nThis version seems to revert the bool-or-str change that would\nbecome useful with a bit more polishing, with docs and tests.\n\nIntended?\n\nIt also seems to repeat many issues that have been pointed out\nduring the reviews of previous revisions.  I'd rather not have to\nrepeat pointing them out all over again, obviously.\n\nI have queued v16 (the one with the beginning of bool-or-str) with\nminimum fixups for issues I pointed out in the review of that\nrevision queued on top of it as SQUASH??? commit.  Please find it in\nthe 'seen' branch.\n\nAlso,\n\n    Subject: Support auto-merge for meld to follow the vim-diff behavior\n\nneeds fixing.\n\ncf. https://git-scm.com/docs/SubmittingPatches#describe-changes\n\nTwo tricks to pick a good title are:\n\n - Read a pageful or two of \"git shortlog --no-merges\" output to get\n   accustomed to the general pattern in the entire project.  It\n   would become clear why titles with \"area:\" prefix help the\n   patches with them easier to locate.\n\n - Read a pageful of \"git shortlog --no-merges -- mergetools\"\n   (i.e. the same but limited to the files you are touching) to see\n   how the changes that contributed over time to build the subsystem\n   are called, so that the new patches can fit in the pattern.\n\nI think something along the lines of\n\n    Subject: [PATCH] mergetool/meld: optionally allow --auto-merge behaviour\n\nor something would fit well.\n\nThanks.\n"},{"id":"404994","messageId":"xmqq4koe8rav.fsf@gitster.c.googlers.com","threadId":"53430","inReplyTo":"xmqqv9idn2yr.fsf@gitster.c.googlers.com","subject":"Re: [PATCH v17] Support auto-merge for meld to follow the vim-diff behavior","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-09-03T21:48:56Z","receivedAt":"2020-09-03T21:49:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> I have queued v16 (the one with the beginning of bool-or-str) with\n> minimum fixups for issues I pointed out in the review of that\n> revision queued on top of it as SQUASH??? commit.  Please find it in\n> the 'seen' branch.\n>\n> Also,\n>\n>     Subject: Support auto-merge for meld to follow the vim-diff behavior\n>\n> needs fixing.\n> ...\n\nAnything new on this topic?  No rush, but I'd hate to see a\nbasically good topic to be left in the stalled state too long.\n\nThanks.\n"},{"id":"405225","messageId":"CAKu6+JEctLopX2O2MmPNnSxqMPXjAqeXjpMPdrtY0J8AWd9L_A@mail.gmail.com","threadId":"53430","inReplyTo":"C35AC799-B4F6-4A5E-92FA-21065310B379@hxcore.ol","subject":"Re: [PATCH v17] Support auto-merge for meld to follow the vim-diff behavior","fromName":"Lin Sun","fromEmail":"lin.sun@zoom.us","sentAt":"2020-09-09T01:31:38Z","receivedAt":"2020-09-09T01:31:55Z","isPatch":true,"sender":{"key":"lin.sun@zoom.us","avatar":null},"body":"Hi Junio,\n\nSorry again, I have to re-send this mail in plain text mode for the\nmail system rejecting it with \" <git@vger.kernel.org> Content-Policy\nreject msg: The message contains HTML subpart, therefore we\n    consider it SPAM or Outlook Virus.\"\n--------------------------------------------------------\nI tried to send an update to you in the morning but now the mail\nmissed from my drafts and “send box”, I’m not sure if the mail already\nsent or not.\nSo I sent this mail with\n“0001-Support-auto-merge-for-meld-to-follow-the-vim-diff-b.patch” for\nassurement.\nIf you already received this patch before, please ignore current mail.\n--------------------------------------------------------\nAfter applying the changes with your SQUASH??? Commit, I test the\ncases with useAutoMerge flag None/true/false/auto, it works like a\ncharm.\nSo I sent out the last patch (no changes since your SQUASH commit),\nplease review it. Thank you.\n\nBest Regards\nLin Sun\n\n\nFrom 1b931e610ddfc02dc2e88234b106e3d3ff841b01 Mon Sep 17 00:00:00 2001\nFrom: Lin Sun <lin.sun@zoom.us>\nDate: Thu, 7 May 2020 07:31:14 +0800\nSubject: [PATCH] Support auto-merge for meld to follow the vim-diff behavior\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n\nMake the mergetool used with \"meld\" backend behave similarly to \"vimdiff\" by\ntelling it to auto-merge non-conflicting parts and highlight the conflicting\nparts when `mergetool.meld.useAutoMerge` is configured with `true`, or `auto`\nfor detecting the `--auto-merge` option automatically.\n\nHelped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\nHelped-by: David Aguilar <davvid@gmail.com>\nSigned-off-by: Lin Sun <lin.sun@zoom.us>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/config/mergetool.txt | 10 +++++\n builtin/config.c                   | 17 ++++++++\n mergetools/meld                    | 85 +++++++++++++++++++++++++++++++-------\n 3 files changed, 96 insertions(+), 16 deletions(-)\n\ndiff --git a/Documentation/config/mergetool.txt b/Documentation/config/mergetool.txt\nindex 09ed31d..16a2744 100644\n--- a/Documentation/config/mergetool.txt\n+++ b/Documentation/config/mergetool.txt\n@@ -30,6 +30,16 @@ mergetool.meld.hasOutput::\n \tto `true` tells Git to unconditionally use the `--output` option,\n \tand `false` avoids using `--output`.\n \n+mergetool.meld.useAutoMerge::\n+\tWhen the `--auto-merge` is given, meld will merge all non-conflicting\n+\tparts automatically, highlight the conflicting parts and wait for\n+\tuser decision.  Setting `mergetool.meld.useAutoMerge` to `true` tells\n+\tGit to unconditionally use the `--auto-merge` option with `meld`.\n+\tSetting this value to `auto` makes git detect whether `--auto-merge`\n+\tis supported and will only use `--auto-merge` when available.  A\n+\tvalue of `false` avoids using `--auto-merge` altogether, and is the\n+\tdefault value.\n+\n mergetool.keepBackup::\n \tAfter performing a merge, the original file with conflict markers\n \tcan be saved as a file with a `.orig` extension.  If this variable\ndiff --git a/builtin/config.c b/builtin/config.c\nindex 5e39f61..ae077c9 100644\n--- a/builtin/config.c\n+++ b/builtin/config.c\n@@ -65,6 +65,7 @@ static int show_scope;\n #define TYPE_PATH\t\t4\n #define TYPE_EXPIRY_DATE\t5\n #define TYPE_COLOR\t\t6\n+#define TYPE_BOOL_OR_STR\t7\n \n #define OPT_CALLBACK_VALUE(s, l, v, h, i) \\\n \t{ OPTION_CALLBACK, (s), (l), (v), NULL, (h), PARSE_OPT_NOARG | \\\n@@ -94,6 +95,8 @@ static int option_parse_type(const struct option *opt, const char *arg,\n \t\t\tnew_type = TYPE_INT;\n \t\telse if (!strcmp(arg, \"bool-or-int\"))\n \t\t\tnew_type = TYPE_BOOL_OR_INT;\n+\t\telse if (!strcmp(arg, \"bool-or-str\"))\n+\t\t\tnew_type = TYPE_BOOL_OR_STR;\n \t\telse if (!strcmp(arg, \"path\"))\n \t\t\tnew_type = TYPE_PATH;\n \t\telse if (!strcmp(arg, \"expiry-date\"))\n@@ -149,6 +152,7 @@ static struct option builtin_config_options[] = {\n \tOPT_CALLBACK_VALUE(0, \"bool\", &type, N_(\"value is \\\"true\\\" or \\\"false\\\"\"), TYPE_BOOL),\n \tOPT_CALLBACK_VALUE(0, \"int\", &type, N_(\"value is decimal number\"), TYPE_INT),\n \tOPT_CALLBACK_VALUE(0, \"bool-or-int\", &type, N_(\"value is --bool or --int\"), TYPE_BOOL_OR_INT),\n+\tOPT_CALLBACK_VALUE(0, \"bool-or-str\", &type, N_(\"value is --bool or string\"), TYPE_BOOL_OR_STR),\n \tOPT_CALLBACK_VALUE(0, \"path\", &type, N_(\"value is a path (file or directory name)\"), TYPE_PATH),\n \tOPT_CALLBACK_VALUE(0, \"expiry-date\", &type, N_(\"value is an expiry date\"), TYPE_EXPIRY_DATE),\n \tOPT_GROUP(N_(\"Other\")),\n@@ -250,6 +254,12 @@ static int format_config(struct strbuf *buf, const char *key_, const char *value\n \t\t\t\tstrbuf_addstr(buf, v ? \"true\" : \"false\");\n \t\t\telse\n \t\t\t\tstrbuf_addf(buf, \"%d\", v);\n+\t\t} else if (type == TYPE_BOOL_OR_STR) {\n+\t\t\tint v = git_parse_maybe_bool(value_);\n+\t\t\tif (v < 0)\n+\t\t\t\tstrbuf_addstr(buf, value_);\n+\t\t\telse\n+\t\t\t\tstrbuf_addstr(buf, v ? \"true\" : \"false\");\n \t\t} else if (type == TYPE_PATH) {\n \t\t\tconst char *v;\n \t\t\tif (git_config_pathname(&v, key_, value_) < 0)\n@@ -411,6 +421,13 @@ static char *normalize_value(const char *key, const char *value)\n \t\telse\n \t\t\treturn xstrdup(v ? \"true\" : \"false\");\n \t}\n+\tif (type == TYPE_BOOL_OR_STR) {\n+\t\tint v = git_parse_maybe_bool(value);\n+\t\tif (v < 0)\n+\t\t\treturn xstrdup(value);\n+\t\telse\n+\t\t\treturn xstrdup(v ? \"true\" : \"false\");\n+\t}\n \tif (type == TYPE_COLOR) {\n \t\tchar v[COLOR_MAXLEN];\n \t\tif (git_config_color(v, key, value))\ndiff --git a/mergetools/meld b/mergetools/meld\nindex 7a08470..aab4ebb 100644\n--- a/mergetools/meld\n+++ b/mergetools/meld\n@@ -3,34 +3,87 @@ diff_cmd () {\n }\n \n merge_cmd () {\n-\tif test -z \"${meld_has_output_option:+set}\"\n+\tcheck_meld_for_features\n+\n+\toption_auto_merge=\n+\tif test \"$meld_use_auto_merge_option\" = true\n \tthen\n-\t\tcheck_meld_for_output_version\n+\t\toption_auto_merge=\"--auto-merge\"\n \tfi\n \n \tif test \"$meld_has_output_option\" = true\n \tthen\n-\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n+\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \telse\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \tfi\n }\n \n-# Check whether we should use 'meld --output <file>'\n-check_meld_for_output_version () {\n-\tmeld_path=\"$(git config mergetool.meld.path)\"\n-\tmeld_path=\"${meld_path:-meld}\"\n+# Get meld help message\n+init_meld_help_msg () {\n+\tif test -z \"$meld_help_msg\"\n+\tthen\n+\t\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n+\t\tmeld_help_msg=$(\"$meld_path\" --help 2>&1)\n+\tfi\n+}\n \n-\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+# Check the features and set flags\n+check_meld_for_features () {\n+\t# Check whether we should use 'meld --output <file>'\n+\tif test -z \"$meld_has_output_option\"\n \tthen\n-\t\t: use configured value\n-\telif \"$meld_path\" --help 2>&1 |\n-\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n+\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+\t\tcase \"$meld_has_output_option\" in\n+\t\ttrue | false)\n+\t\t\t: use configured value\n+\t\t\t;;\n+\t\t*)\n+\t\t\t: empty or invalid configured value, detecting \"--output\" automatically\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--output=\"* | *'[OPTION...]'*)\n+\t\t\t\t# All version that has [OPTION...] supports --output\n+\t\t\t\tmeld_has_output_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_has_output_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\tesac\n+\tfi\n+\t# Check whether we should use 'meld --auto-merge ...'\n+\tif test -z \"$meld_use_auto_merge_option\"\n \tthen\n-\t\t: old ones mention --output and new ones just say OPTION...\n-\t\tmeld_has_output_option=true\n-\telse\n-\t\tmeld_has_output_option=false\n+\t\tmeld_use_auto_merge_option=$(\n+\t\t\tgit config --bool-or-str mergetool.meld.useAutoMerge\n+\t\t)\n+\t\tcase \"$meld_use_auto_merge_option\" in\n+\t\ttrue | false)\n+\t\t\t: use well formatted boolean value\n+\t\t\t;;\n+\t\tauto)\n+\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--auto-merge\"* | *'[OPTION...]'*)\n+\t\t\t\tmeld_use_auto_merge_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_use_auto_merge_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\t\"\")\n+\t\t\tmeld_use_auto_merge_option=false\n+\t\t\t;;\n+\t\t*)\n+\t\t\tdie \"unknown mergetool.meld.useAutoMerge: $meld_use_auto_merge_option\"\n+\t\t\t;;\n+\t\tesac\n \tfi\n }\n-- \n2.2.0\n\n"},{"id":"405287","messageId":"xmqqo8meu1el.fsf@gitster.c.googlers.com","threadId":"53430","inReplyTo":"CAKu6+JEctLopX2O2MmPNnSxqMPXjAqeXjpMPdrtY0J8AWd9L_A@mail.gmail.com","subject":"Re: [PATCH v17] Support auto-merge for meld to follow the vim-diff behavior","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-09-09T20:43:14Z","receivedAt":"2020-09-09T20:43:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks.  Will replace.\n\nFor those who are watching from the sideline, here is the patch inline.\n\n-- >8 --\nFrom: Lin Sun <lin.sun@zoom.us>\nDate: Thu, 7 May 2020 07:31:14 +0800\nSubject: [PATCH] Support auto-merge for meld to follow the vim-diff behavior\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n\nMake the mergetool used with \"meld\" backend behave similarly to \"vimdiff\" by\ntelling it to auto-merge non-conflicting parts and highlight the conflicting\nparts when `mergetool.meld.useAutoMerge` is configured with `true`, or `auto`\nfor detecting the `--auto-merge` option automatically.\n\nHelped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\nHelped-by: David Aguilar <davvid@gmail.com>\nSigned-off-by: Lin Sun <lin.sun@zoom.us>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/config/mergetool.txt | 10 ++++\n builtin/config.c                   | 17 ++++++\n mergetools/meld                    | 85 ++++++++++++++++++++++++------\n 3 files changed, 96 insertions(+), 16 deletions(-)\n\ndiff --git a/Documentation/config/mergetool.txt b/Documentation/config/mergetool.txt\nindex 09ed31dbfa..16a27443a3 100644\n--- a/Documentation/config/mergetool.txt\n+++ b/Documentation/config/mergetool.txt\n@@ -30,6 +30,16 @@ mergetool.meld.hasOutput::\n \tto `true` tells Git to unconditionally use the `--output` option,\n \tand `false` avoids using `--output`.\n \n+mergetool.meld.useAutoMerge::\n+\tWhen the `--auto-merge` is given, meld will merge all non-conflicting\n+\tparts automatically, highlight the conflicting parts and wait for\n+\tuser decision.  Setting `mergetool.meld.useAutoMerge` to `true` tells\n+\tGit to unconditionally use the `--auto-merge` option with `meld`.\n+\tSetting this value to `auto` makes git detect whether `--auto-merge`\n+\tis supported and will only use `--auto-merge` when available.  A\n+\tvalue of `false` avoids using `--auto-merge` altogether, and is the\n+\tdefault value.\n+\n mergetool.keepBackup::\n \tAfter performing a merge, the original file with conflict markers\n \tcan be saved as a file with a `.orig` extension.  If this variable\ndiff --git a/builtin/config.c b/builtin/config.c\nindex ee4aef6a35..7891e070a4 100644\n--- a/builtin/config.c\n+++ b/builtin/config.c\n@@ -65,6 +65,7 @@ static int show_scope;\n #define TYPE_PATH\t\t4\n #define TYPE_EXPIRY_DATE\t5\n #define TYPE_COLOR\t\t6\n+#define TYPE_BOOL_OR_STR\t7\n \n #define OPT_CALLBACK_VALUE(s, l, v, h, i) \\\n \t{ OPTION_CALLBACK, (s), (l), (v), NULL, (h), PARSE_OPT_NOARG | \\\n@@ -94,6 +95,8 @@ static int option_parse_type(const struct option *opt, const char *arg,\n \t\t\tnew_type = TYPE_INT;\n \t\telse if (!strcmp(arg, \"bool-or-int\"))\n \t\t\tnew_type = TYPE_BOOL_OR_INT;\n+\t\telse if (!strcmp(arg, \"bool-or-str\"))\n+\t\t\tnew_type = TYPE_BOOL_OR_STR;\n \t\telse if (!strcmp(arg, \"path\"))\n \t\t\tnew_type = TYPE_PATH;\n \t\telse if (!strcmp(arg, \"expiry-date\"))\n@@ -149,6 +152,7 @@ static struct option builtin_config_options[] = {\n \tOPT_CALLBACK_VALUE(0, \"bool\", &type, N_(\"value is \\\"true\\\" or \\\"false\\\"\"), TYPE_BOOL),\n \tOPT_CALLBACK_VALUE(0, \"int\", &type, N_(\"value is decimal number\"), TYPE_INT),\n \tOPT_CALLBACK_VALUE(0, \"bool-or-int\", &type, N_(\"value is --bool or --int\"), TYPE_BOOL_OR_INT),\n+\tOPT_CALLBACK_VALUE(0, \"bool-or-str\", &type, N_(\"value is --bool or string\"), TYPE_BOOL_OR_STR),\n \tOPT_CALLBACK_VALUE(0, \"path\", &type, N_(\"value is a path (file or directory name)\"), TYPE_PATH),\n \tOPT_CALLBACK_VALUE(0, \"expiry-date\", &type, N_(\"value is an expiry date\"), TYPE_EXPIRY_DATE),\n \tOPT_GROUP(N_(\"Other\")),\n@@ -250,6 +254,12 @@ static int format_config(struct strbuf *buf, const char *key_, const char *value\n \t\t\t\tstrbuf_addstr(buf, v ? \"true\" : \"false\");\n \t\t\telse\n \t\t\t\tstrbuf_addf(buf, \"%d\", v);\n+\t\t} else if (type == TYPE_BOOL_OR_STR) {\n+\t\t\tint v = git_parse_maybe_bool(value_);\n+\t\t\tif (v < 0)\n+\t\t\t\tstrbuf_addstr(buf, value_);\n+\t\t\telse\n+\t\t\t\tstrbuf_addstr(buf, v ? \"true\" : \"false\");\n \t\t} else if (type == TYPE_PATH) {\n \t\t\tconst char *v;\n \t\t\tif (git_config_pathname(&v, key_, value_) < 0)\n@@ -411,6 +421,13 @@ static char *normalize_value(const char *key, const char *value)\n \t\telse\n \t\t\treturn xstrdup(v ? \"true\" : \"false\");\n \t}\n+\tif (type == TYPE_BOOL_OR_STR) {\n+\t\tint v = git_parse_maybe_bool(value);\n+\t\tif (v < 0)\n+\t\t\treturn xstrdup(value);\n+\t\telse\n+\t\t\treturn xstrdup(v ? \"true\" : \"false\");\n+\t}\n \tif (type == TYPE_COLOR) {\n \t\tchar v[COLOR_MAXLEN];\n \t\tif (git_config_color(v, key, value))\ndiff --git a/mergetools/meld b/mergetools/meld\nindex 7a08470f88..aab4ebb935 100644\n--- a/mergetools/meld\n+++ b/mergetools/meld\n@@ -3,34 +3,87 @@ diff_cmd () {\n }\n \n merge_cmd () {\n-\tif test -z \"${meld_has_output_option:+set}\"\n+\tcheck_meld_for_features\n+\n+\toption_auto_merge=\n+\tif test \"$meld_use_auto_merge_option\" = true\n \tthen\n-\t\tcheck_meld_for_output_version\n+\t\toption_auto_merge=\"--auto-merge\"\n \tfi\n \n \tif test \"$meld_has_output_option\" = true\n \tthen\n-\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n+\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \telse\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \tfi\n }\n \n-# Check whether we should use 'meld --output <file>'\n-check_meld_for_output_version () {\n-\tmeld_path=\"$(git config mergetool.meld.path)\"\n-\tmeld_path=\"${meld_path:-meld}\"\n+# Get meld help message\n+init_meld_help_msg () {\n+\tif test -z \"$meld_help_msg\"\n+\tthen\n+\t\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n+\t\tmeld_help_msg=$(\"$meld_path\" --help 2>&1)\n+\tfi\n+}\n \n-\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+# Check the features and set flags\n+check_meld_for_features () {\n+\t# Check whether we should use 'meld --output <file>'\n+\tif test -z \"$meld_has_output_option\"\n \tthen\n-\t\t: use configured value\n-\telif \"$meld_path\" --help 2>&1 |\n-\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n+\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+\t\tcase \"$meld_has_output_option\" in\n+\t\ttrue | false)\n+\t\t\t: use configured value\n+\t\t\t;;\n+\t\t*)\n+\t\t\t: empty or invalid configured value, detecting \"--output\" automatically\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--output=\"* | *'[OPTION...]'*)\n+\t\t\t\t# All version that has [OPTION...] supports --output\n+\t\t\t\tmeld_has_output_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_has_output_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\tesac\n+\tfi\n+\t# Check whether we should use 'meld --auto-merge ...'\n+\tif test -z \"$meld_use_auto_merge_option\"\n \tthen\n-\t\t: old ones mention --output and new ones just say OPTION...\n-\t\tmeld_has_output_option=true\n-\telse\n-\t\tmeld_has_output_option=false\n+\t\tmeld_use_auto_merge_option=$(\n+\t\t\tgit config --bool-or-str mergetool.meld.useAutoMerge\n+\t\t)\n+\t\tcase \"$meld_use_auto_merge_option\" in\n+\t\ttrue | false)\n+\t\t\t: use well formatted boolean value\n+\t\t\t;;\n+\t\tauto)\n+\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--auto-merge\"* | *'[OPTION...]'*)\n+\t\t\t\tmeld_use_auto_merge_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_use_auto_merge_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\t\"\")\n+\t\t\tmeld_use_auto_merge_option=false\n+\t\t\t;;\n+\t\t*)\n+\t\t\tdie \"unknown mergetool.meld.useAutoMerge: $meld_use_auto_merge_option\"\n+\t\t\t;;\n+\t\tesac\n \tfi\n }\n-- \n2.28.0-558-g7a0184fd7b\n\n"},{"id":"405466","messageId":"pull.781.v18.git.git.1599895268433.gitgitgadget@gmail.com","threadId":"53430","inReplyTo":"pull.781.v17.git.git.1594596738929.gitgitgadget@gmail.com","subject":"[PATCH v18] Support auto-merge for meld to follow the vim-diff behavior","fromName":"sunlin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-12T07:21:08Z","receivedAt":"2020-09-12T07:21:17Z","isPatch":true,"sender":{"key":"name:sunlin","avatar":null},"body":"From: Lin Sun <lin.sun@zoom.us>\n\nMake the mergetool used with \"meld\" backend behave similarly to \"vimdiff\" by\ntelling it to auto-merge non-conflicting parts and highlight the conflicting\nparts when `mergetool.meld.useAutoMerge` is configured with `true`, or `auto`\nfor detecting the `--auto-merge` option automatically.\n\nHelped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\nHelped-by: David Aguilar <davvid@gmail.com>\nSigned-off-by: Lin Sun <lin.sun@zoom.us>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n    Enable auto-merge for meld to follow the vimdiff beharior\n    \n    Hi, the mergetool \"meld\" does NOT merge the no-conflict changes, while\n    the mergetool \"vimdiff\" will merge the no-conflict changes and highlight\n    the conflict parts. This patch will make the mergetool \"meld\" similar to\n    \"vimdiff\", auto-merge the no-conflict changes, highlight conflict parts.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-781%2Fsunlin7%2Fmaster-v18\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-781/sunlin7/master-v18\nPull-Request: https://github.com/git/git/pull/781\n\nRange-diff vs v17:\n\n 1:  ce4e4cbfc0 ! 1:  1b931e610d Support auto-merge for meld to follow the vim-diff behavior\n     @@ Documentation/config/mergetool.txt: mergetool.meld.hasOutput::\n       \tAfter performing a merge, the original file with conflict markers\n       \tcan be saved as a file with a `.orig` extension.  If this variable\n      \n     + ## builtin/config.c ##\n     +@@ builtin/config.c: static int show_scope;\n     + #define TYPE_PATH\t\t4\n     + #define TYPE_EXPIRY_DATE\t5\n     + #define TYPE_COLOR\t\t6\n     ++#define TYPE_BOOL_OR_STR\t7\n     + \n     + #define OPT_CALLBACK_VALUE(s, l, v, h, i) \\\n     + \t{ OPTION_CALLBACK, (s), (l), (v), NULL, (h), PARSE_OPT_NOARG | \\\n     +@@ builtin/config.c: static int option_parse_type(const struct option *opt, const char *arg,\n     + \t\t\tnew_type = TYPE_INT;\n     + \t\telse if (!strcmp(arg, \"bool-or-int\"))\n     + \t\t\tnew_type = TYPE_BOOL_OR_INT;\n     ++\t\telse if (!strcmp(arg, \"bool-or-str\"))\n     ++\t\t\tnew_type = TYPE_BOOL_OR_STR;\n     + \t\telse if (!strcmp(arg, \"path\"))\n     + \t\t\tnew_type = TYPE_PATH;\n     + \t\telse if (!strcmp(arg, \"expiry-date\"))\n     +@@ builtin/config.c: static struct option builtin_config_options[] = {\n     + \tOPT_CALLBACK_VALUE(0, \"bool\", &type, N_(\"value is \\\"true\\\" or \\\"false\\\"\"), TYPE_BOOL),\n     + \tOPT_CALLBACK_VALUE(0, \"int\", &type, N_(\"value is decimal number\"), TYPE_INT),\n     + \tOPT_CALLBACK_VALUE(0, \"bool-or-int\", &type, N_(\"value is --bool or --int\"), TYPE_BOOL_OR_INT),\n     ++\tOPT_CALLBACK_VALUE(0, \"bool-or-str\", &type, N_(\"value is --bool or string\"), TYPE_BOOL_OR_STR),\n     + \tOPT_CALLBACK_VALUE(0, \"path\", &type, N_(\"value is a path (file or directory name)\"), TYPE_PATH),\n     + \tOPT_CALLBACK_VALUE(0, \"expiry-date\", &type, N_(\"value is an expiry date\"), TYPE_EXPIRY_DATE),\n     + \tOPT_GROUP(N_(\"Other\")),\n     +@@ builtin/config.c: static int format_config(struct strbuf *buf, const char *key_, const char *value\n     + \t\t\t\tstrbuf_addstr(buf, v ? \"true\" : \"false\");\n     + \t\t\telse\n     + \t\t\t\tstrbuf_addf(buf, \"%d\", v);\n     ++\t\t} else if (type == TYPE_BOOL_OR_STR) {\n     ++\t\t\tint v = git_parse_maybe_bool(value_);\n     ++\t\t\tif (v < 0)\n     ++\t\t\t\tstrbuf_addstr(buf, value_);\n     ++\t\t\telse\n     ++\t\t\t\tstrbuf_addstr(buf, v ? \"true\" : \"false\");\n     + \t\t} else if (type == TYPE_PATH) {\n     + \t\t\tconst char *v;\n     + \t\t\tif (git_config_pathname(&v, key_, value_) < 0)\n     +@@ builtin/config.c: static char *normalize_value(const char *key, const char *value)\n     + \t\telse\n     + \t\t\treturn xstrdup(v ? \"true\" : \"false\");\n     + \t}\n     ++\tif (type == TYPE_BOOL_OR_STR) {\n     ++\t\tint v = git_parse_maybe_bool(value);\n     ++\t\tif (v < 0)\n     ++\t\t\treturn xstrdup(value);\n     ++\t\telse\n     ++\t\t\treturn xstrdup(v ? \"true\" : \"false\");\n     ++\t}\n     + \tif (type == TYPE_COLOR) {\n     + \t\tchar v[COLOR_MAXLEN];\n     + \t\tif (git_config_color(v, key, value))\n     +\n       ## mergetools/meld ##\n      @@ mergetools/meld: diff_cmd () {\n       }\n     @@ mergetools/meld: diff_cmd () {\n      -\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n      +\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n      +\t\tcase \"$meld_has_output_option\" in\n     -+\t\ttrue|false)\n     ++\t\ttrue | false)\n      +\t\t\t: use configured value\n      +\t\t\t;;\n      +\t\t*)\n     @@ mergetools/meld: diff_cmd () {\n      +\t\t\tinit_meld_help_msg\n      +\n      +\t\t\tcase \"$meld_help_msg\" in\n     -+\t\t\t*\"--output=\"*|*'[OPTION...]'*)\n     ++\t\t\t*\"--output=\"* | *'[OPTION...]'*)\n      +\t\t\t\t# All version that has [OPTION...] supports --output\n      +\t\t\t\tmeld_has_output_option=true\n      +\t\t\t\t;;\n     @@ mergetools/meld: diff_cmd () {\n      -\t\tmeld_has_output_option=true\n      -\telse\n      -\t\tmeld_has_output_option=false\n     -+\t\tmeld_use_auto_merge_option=$(git config mergetool.meld.useAutoMerge)\n     ++\t\tmeld_use_auto_merge_option=$(\n     ++\t\t\tgit config --bool-or-str mergetool.meld.useAutoMerge\n     ++\t\t)\n      +\t\tcase \"$meld_use_auto_merge_option\" in\n     -+\t\ttrue|false)\n     ++\t\ttrue | false)\n      +\t\t\t: use well formatted boolean value\n      +\t\t\t;;\n      +\t\tauto)\n     @@ mergetools/meld: diff_cmd () {\n      +\t\t\tinit_meld_help_msg\n      +\n      +\t\t\tcase \"$meld_help_msg\" in\n     -+\t\t\t*\"--auto-merge\"*|*'[OPTION...]'*)\n     ++\t\t\t*\"--auto-merge\"* | *'[OPTION...]'*)\n      +\t\t\t\tmeld_use_auto_merge_option=true\n      +\t\t\t\t;;\n      +\t\t\t*)\n     @@ mergetools/meld: diff_cmd () {\n      +\t\t\t\t;;\n      +\t\t\tesac\n      +\t\t\t;;\n     ++\t\t\"\")\n     ++\t\t\tmeld_use_auto_merge_option=false\n     ++\t\t\t;;\n      +\t\t*)\n     -+\t\t\t# try other boolean value with git\n     -+\t\t\tif meld_use_auto_merge_option=$(\n     -+\t\t\t\t git config --bool mergetool.meld.useAutoMerge)\n     -+\t\t\tthen\n     -+\t\t\t\t: use normalized boolean value\n     -+\t\t\telse\n     -+\t\t\t\tmeld_use_auto_merge_option=false\n     -+\t\t\tfi\n     ++\t\t\tdie \"unknown mergetool.meld.useAutoMerge: $meld_use_auto_merge_option\"\n      +\t\t\t;;\n      +\t\tesac\n       \tfi\n\n\n Documentation/config/mergetool.txt | 10 ++++\n builtin/config.c                   | 17 ++++++\n mergetools/meld                    | 85 ++++++++++++++++++++++++------\n 3 files changed, 96 insertions(+), 16 deletions(-)\n\ndiff --git a/Documentation/config/mergetool.txt b/Documentation/config/mergetool.txt\nindex 09ed31dbfa..16a27443a3 100644\n--- a/Documentation/config/mergetool.txt\n+++ b/Documentation/config/mergetool.txt\n@@ -30,6 +30,16 @@ mergetool.meld.hasOutput::\n \tto `true` tells Git to unconditionally use the `--output` option,\n \tand `false` avoids using `--output`.\n \n+mergetool.meld.useAutoMerge::\n+\tWhen the `--auto-merge` is given, meld will merge all non-conflicting\n+\tparts automatically, highlight the conflicting parts and wait for\n+\tuser decision.  Setting `mergetool.meld.useAutoMerge` to `true` tells\n+\tGit to unconditionally use the `--auto-merge` option with `meld`.\n+\tSetting this value to `auto` makes git detect whether `--auto-merge`\n+\tis supported and will only use `--auto-merge` when available.  A\n+\tvalue of `false` avoids using `--auto-merge` altogether, and is the\n+\tdefault value.\n+\n mergetool.keepBackup::\n \tAfter performing a merge, the original file with conflict markers\n \tcan be saved as a file with a `.orig` extension.  If this variable\ndiff --git a/builtin/config.c b/builtin/config.c\nindex 5e39f61885..ae077c9f2f 100644\n--- a/builtin/config.c\n+++ b/builtin/config.c\n@@ -65,6 +65,7 @@ static int show_scope;\n #define TYPE_PATH\t\t4\n #define TYPE_EXPIRY_DATE\t5\n #define TYPE_COLOR\t\t6\n+#define TYPE_BOOL_OR_STR\t7\n \n #define OPT_CALLBACK_VALUE(s, l, v, h, i) \\\n \t{ OPTION_CALLBACK, (s), (l), (v), NULL, (h), PARSE_OPT_NOARG | \\\n@@ -94,6 +95,8 @@ static int option_parse_type(const struct option *opt, const char *arg,\n \t\t\tnew_type = TYPE_INT;\n \t\telse if (!strcmp(arg, \"bool-or-int\"))\n \t\t\tnew_type = TYPE_BOOL_OR_INT;\n+\t\telse if (!strcmp(arg, \"bool-or-str\"))\n+\t\t\tnew_type = TYPE_BOOL_OR_STR;\n \t\telse if (!strcmp(arg, \"path\"))\n \t\t\tnew_type = TYPE_PATH;\n \t\telse if (!strcmp(arg, \"expiry-date\"))\n@@ -149,6 +152,7 @@ static struct option builtin_config_options[] = {\n \tOPT_CALLBACK_VALUE(0, \"bool\", &type, N_(\"value is \\\"true\\\" or \\\"false\\\"\"), TYPE_BOOL),\n \tOPT_CALLBACK_VALUE(0, \"int\", &type, N_(\"value is decimal number\"), TYPE_INT),\n \tOPT_CALLBACK_VALUE(0, \"bool-or-int\", &type, N_(\"value is --bool or --int\"), TYPE_BOOL_OR_INT),\n+\tOPT_CALLBACK_VALUE(0, \"bool-or-str\", &type, N_(\"value is --bool or string\"), TYPE_BOOL_OR_STR),\n \tOPT_CALLBACK_VALUE(0, \"path\", &type, N_(\"value is a path (file or directory name)\"), TYPE_PATH),\n \tOPT_CALLBACK_VALUE(0, \"expiry-date\", &type, N_(\"value is an expiry date\"), TYPE_EXPIRY_DATE),\n \tOPT_GROUP(N_(\"Other\")),\n@@ -250,6 +254,12 @@ static int format_config(struct strbuf *buf, const char *key_, const char *value\n \t\t\t\tstrbuf_addstr(buf, v ? \"true\" : \"false\");\n \t\t\telse\n \t\t\t\tstrbuf_addf(buf, \"%d\", v);\n+\t\t} else if (type == TYPE_BOOL_OR_STR) {\n+\t\t\tint v = git_parse_maybe_bool(value_);\n+\t\t\tif (v < 0)\n+\t\t\t\tstrbuf_addstr(buf, value_);\n+\t\t\telse\n+\t\t\t\tstrbuf_addstr(buf, v ? \"true\" : \"false\");\n \t\t} else if (type == TYPE_PATH) {\n \t\t\tconst char *v;\n \t\t\tif (git_config_pathname(&v, key_, value_) < 0)\n@@ -411,6 +421,13 @@ static char *normalize_value(const char *key, const char *value)\n \t\telse\n \t\t\treturn xstrdup(v ? \"true\" : \"false\");\n \t}\n+\tif (type == TYPE_BOOL_OR_STR) {\n+\t\tint v = git_parse_maybe_bool(value);\n+\t\tif (v < 0)\n+\t\t\treturn xstrdup(value);\n+\t\telse\n+\t\t\treturn xstrdup(v ? \"true\" : \"false\");\n+\t}\n \tif (type == TYPE_COLOR) {\n \t\tchar v[COLOR_MAXLEN];\n \t\tif (git_config_color(v, key, value))\ndiff --git a/mergetools/meld b/mergetools/meld\nindex 7a08470f88..aab4ebb935 100644\n--- a/mergetools/meld\n+++ b/mergetools/meld\n@@ -3,34 +3,87 @@ diff_cmd () {\n }\n \n merge_cmd () {\n-\tif test -z \"${meld_has_output_option:+set}\"\n+\tcheck_meld_for_features\n+\n+\toption_auto_merge=\n+\tif test \"$meld_use_auto_merge_option\" = true\n \tthen\n-\t\tcheck_meld_for_output_version\n+\t\toption_auto_merge=\"--auto-merge\"\n \tfi\n \n \tif test \"$meld_has_output_option\" = true\n \tthen\n-\t\t\"$merge_tool_path\" --output=\"$MERGED\" \\\n+\t\t\"$merge_tool_path\" $option_auto_merge --output=\"$MERGED\" \\\n \t\t\t\"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \telse\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" $option_auto_merge \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \tfi\n }\n \n-# Check whether we should use 'meld --output <file>'\n-check_meld_for_output_version () {\n-\tmeld_path=\"$(git config mergetool.meld.path)\"\n-\tmeld_path=\"${meld_path:-meld}\"\n+# Get meld help message\n+init_meld_help_msg () {\n+\tif test -z \"$meld_help_msg\"\n+\tthen\n+\t\tmeld_path=\"$(git config mergetool.meld.path || echo meld)\"\n+\t\tmeld_help_msg=$(\"$meld_path\" --help 2>&1)\n+\tfi\n+}\n \n-\tif meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+# Check the features and set flags\n+check_meld_for_features () {\n+\t# Check whether we should use 'meld --output <file>'\n+\tif test -z \"$meld_has_output_option\"\n \tthen\n-\t\t: use configured value\n-\telif \"$meld_path\" --help 2>&1 |\n-\t\tgrep -e '--output=' -e '\\[OPTION\\.\\.\\.\\]' >/dev/null\n+\t\tmeld_has_output_option=$(git config --bool mergetool.meld.hasOutput)\n+\t\tcase \"$meld_has_output_option\" in\n+\t\ttrue | false)\n+\t\t\t: use configured value\n+\t\t\t;;\n+\t\t*)\n+\t\t\t: empty or invalid configured value, detecting \"--output\" automatically\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--output=\"* | *'[OPTION...]'*)\n+\t\t\t\t# All version that has [OPTION...] supports --output\n+\t\t\t\tmeld_has_output_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_has_output_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\tesac\n+\tfi\n+\t# Check whether we should use 'meld --auto-merge ...'\n+\tif test -z \"$meld_use_auto_merge_option\"\n \tthen\n-\t\t: old ones mention --output and new ones just say OPTION...\n-\t\tmeld_has_output_option=true\n-\telse\n-\t\tmeld_has_output_option=false\n+\t\tmeld_use_auto_merge_option=$(\n+\t\t\tgit config --bool-or-str mergetool.meld.useAutoMerge\n+\t\t)\n+\t\tcase \"$meld_use_auto_merge_option\" in\n+\t\ttrue | false)\n+\t\t\t: use well formatted boolean value\n+\t\t\t;;\n+\t\tauto)\n+\t\t\t# testing the \"--auto-merge\" option only if config is \"auto\"\n+\t\t\tinit_meld_help_msg\n+\n+\t\t\tcase \"$meld_help_msg\" in\n+\t\t\t*\"--auto-merge\"* | *'[OPTION...]'*)\n+\t\t\t\tmeld_use_auto_merge_option=true\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmeld_use_auto_merge_option=false\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\t\"\")\n+\t\t\tmeld_use_auto_merge_option=false\n+\t\t\t;;\n+\t\t*)\n+\t\t\tdie \"unknown mergetool.meld.useAutoMerge: $meld_use_auto_merge_option\"\n+\t\t\t;;\n+\t\tesac\n \tfi\n }\n\nbase-commit: 3a238e539bcdfe3f9eb5010fd218640c1b499f7a\n-- \ngitgitgadget\n"},{"id":"405526","messageId":"xmqqr1r4jf54.fsf@gitster.c.googlers.com","threadId":"53430","inReplyTo":"pull.781.v18.git.git.1599895268433.gitgitgadget@gmail.com","subject":"Re: [PATCH v18] Support auto-merge for meld to follow the vim-diff behavior","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-09-14T20:07:51Z","receivedAt":"2020-09-14T20:08:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"sunlin via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Lin Sun <lin.sun@zoom.us>\n>\n> Make the mergetool used with \"meld\" backend behave similarly to \"vimdiff\" by\n> telling it to auto-merge non-conflicting parts and highlight the conflicting\n> parts when `mergetool.meld.useAutoMerge` is configured with `true`, or `auto`\n> for detecting the `--auto-merge` option automatically.\n>\n> Helped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\n> Helped-by: David Aguilar <davvid@gmail.com>\n> Signed-off-by: Lin Sun <lin.sun@zoom.us>\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n>     Enable auto-merge for meld to follow the vimdiff beharior\n>     \n>     Hi, the mergetool \"meld\" does NOT merge the no-conflict changes, while\n>     the mergetool \"vimdiff\" will merge the no-conflict changes and highlight\n>     the conflict parts. This patch will make the mergetool \"meld\" similar to\n>     \"vimdiff\", auto-merge the no-conflict changes, highlight conflict parts.\n\nThanks.\n"},{"id":"405542","messageId":"CAKu6+JH6vJsJ8Gj75qnKefqOh8Dk3XcPt+vjpTbYahY4jzSAeQ@mail.gmail.com","threadId":"53430","inReplyTo":"xmqqr1r4jf54.fsf@gitster.c.googlers.com","subject":"Re: [PATCH v18] Support auto-merge for meld to follow the vim-diff behavior","fromName":"Lin Sun","fromEmail":"lin.sun@zoom.us","sentAt":"2020-09-15T00:55:09Z","receivedAt":"2020-09-15T00:55:28Z","isPatch":true,"sender":{"key":"lin.sun@zoom.us","avatar":null},"body":"Hi Junio,\n\n> conflict …\nIt’s my typo. Thank you for fixing it.\n\nBest Regards\nLin Sun\n"}]}