diff mbox series

[v6,2/2] mergetool: Add per-tool support for the autoMerge flag

Message ID 20201227205835.502556-3-seth@eseth.com (mailing list archive)
State New, archived
Headers show
Series mergetool: remove unconflicted lines | expand

Commit Message

Seth House Dec. 27, 2020, 8:58 p.m. UTC
Keep the global mergetool flag and add a per-tool override flag so that
users may enable the flag for one tool and disable it for another.

Signed-off-by: Seth House <seth@eseth.com>
---
 Documentation/config/mergetool.txt | 3 +++
 git-mergetool.sh                   | 5 ++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

Comments

Junio C Hamano Dec. 27, 2020, 10:31 p.m. UTC | #1
Seth House <seth@eseth.com> writes:

> Keep the global mergetool flag and add a per-tool override flag so that
> users may enable the flag for one tool and disable it for another.
>
> Signed-off-by: Seth House <seth@eseth.com>
> ---
>  Documentation/config/mergetool.txt | 3 +++
>  git-mergetool.sh                   | 5 ++++-
>  2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/config/mergetool.txt b/Documentation/config/mergetool.txt
> index 43af7a96f9..7f32281a61 100644
> --- a/Documentation/config/mergetool.txt
> +++ b/Documentation/config/mergetool.txt
> @@ -21,6 +21,9 @@ mergetool.<tool>.trustExitCode::
>  	if the file has been updated, otherwise the user is prompted to
>  	indicate the success of the merge.
>  
> +mergetool.<tool>.autoMerge::
> +	Automatically resolve conflicts that don't require user intervention.
> +
>  mergetool.meld.hasOutput::
>  	Older versions of `meld` do not support the `--output` option.
>  	Git will attempt to detect whether `meld` supports `--output`
> diff --git a/git-mergetool.sh b/git-mergetool.sh
> index 6e86d3b492..81df301734 100755
> --- a/git-mergetool.sh
> +++ b/git-mergetool.sh
> @@ -323,7 +323,10 @@ merge_file () {
>  	checkout_staged_file 2 "$MERGED" "$LOCAL"
>  	checkout_staged_file 3 "$MERGED" "$REMOTE"
>  
> -	if test "$(git config --bool mergetool.autoMerge)" = "true"
> +	if test "$(
> +		git config --get --bool "mergetool.$merge_tool.automerge" ||
> +		git config --get --bool "mergetool.automerge" ||
> +		echo true)" = true

Your [v6 1/2] that you build this step on does not enable the
feature by default, but this step does; it deserves to be documented
and mentioned in the proposed log message.

But I think you'd want to build this step on top of newer one, if
only to take the portability fix to the tests, and that patch
enables the feature by default, so ...

>  	then
>  		git merge-file --diff3 -q -p "$LOCAL" "$BASE" "$REMOTE" >"$DIFF3"
>  		sed -e '/^<<<<<<< /,/^||||||| /d' -e '/^=======\r\?$/,/^>>>>>>> /d' "$DIFF3" >"$BASE"

Thanks.
diff mbox series

Patch

diff --git a/Documentation/config/mergetool.txt b/Documentation/config/mergetool.txt
index 43af7a96f9..7f32281a61 100644
--- a/Documentation/config/mergetool.txt
+++ b/Documentation/config/mergetool.txt
@@ -21,6 +21,9 @@  mergetool.<tool>.trustExitCode::
 	if the file has been updated, otherwise the user is prompted to
 	indicate the success of the merge.
 
+mergetool.<tool>.autoMerge::
+	Automatically resolve conflicts that don't require user intervention.
+
 mergetool.meld.hasOutput::
 	Older versions of `meld` do not support the `--output` option.
 	Git will attempt to detect whether `meld` supports `--output`
diff --git a/git-mergetool.sh b/git-mergetool.sh
index 6e86d3b492..81df301734 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -323,7 +323,10 @@  merge_file () {
 	checkout_staged_file 2 "$MERGED" "$LOCAL"
 	checkout_staged_file 3 "$MERGED" "$REMOTE"
 
-	if test "$(git config --bool mergetool.autoMerge)" = "true"
+	if test "$(
+		git config --get --bool "mergetool.$merge_tool.automerge" ||
+		git config --get --bool "mergetool.automerge" ||
+		echo true)" = true
 	then
 		git merge-file --diff3 -q -p "$LOCAL" "$BASE" "$REMOTE" >"$DIFF3"
 		sed -e '/^<<<<<<< /,/^||||||| /d' -e '/^=======\r\?$/,/^>>>>>>> /d' "$DIFF3" >"$BASE"