From patchwork Mon Dec 28 04:54:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth House X-Patchwork-Id: 11990837 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA098C433E6 for ; Mon, 28 Dec 2020 04:55:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D5AD20786 for ; Mon, 28 Dec 2020 04:55:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727711AbgL1Ezn (ORCPT ); Sun, 27 Dec 2020 23:55:43 -0500 Received: from out01.mta.xmission.com ([166.70.13.231]:55992 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727704AbgL1Ezn (ORCPT ); Sun, 27 Dec 2020 23:55:43 -0500 Received: from in02.mta.xmission.com ([166.70.13.52]) by out01.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1ktkYg-008i4y-1j; Sun, 27 Dec 2020 21:55:02 -0700 Received: from mta4.zcs.xmission.com ([166.70.13.68]) by in02.mta.xmission.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1ktkYe-00Gtyg-Qq; Sun, 27 Dec 2020 21:55:01 -0700 Received: from localhost (localhost [127.0.0.1]) by mta4.zcs.xmission.com (Postfix) with ESMTP id B25DE5004ED; Sun, 27 Dec 2020 21:55:00 -0700 (MST) X-Amavis-Modified: Mail body modified (using disclaimer) - mta4.zcs.xmission.com Received: from mta4.zcs.xmission.com ([127.0.0.1]) by localhost (mta4.zcs.xmission.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id M9NwLpKAn4lq; Sun, 27 Dec 2020 21:55:00 -0700 (MST) Received: from localhost.localdomain (unknown [139.60.10.209]) by mta4.zcs.xmission.com (Postfix) with ESMTPSA id C6F80500511; Sun, 27 Dec 2020 21:54:59 -0700 (MST) From: Seth House To: git@vger.kernel.org Cc: Felipe Contreras , Seth House Date: Sun, 27 Dec 2020 21:54:24 -0700 Message-Id: <20201228045427.1166911-2-seth@eseth.com> X-Mailer: git-send-email 2.30.0.rc2.4.g8f3eabcc0e In-Reply-To: <20201228045427.1166911-1-seth@eseth.com> References: <20201228004152.522421-1-seth@eseth.com> <20201228045427.1166911-1-seth@eseth.com> MIME-Version: 1.0 X-XM-SPF: eid=1ktkYe-00Gtyg-Qq;;;mid=<20201228045427.1166911-2-seth@eseth.com>;;;hst=in02.mta.xmission.com;;;ip=166.70.13.68;;;frm=seth@eseth.com;;;spf=none X-SA-Exim-Connect-IP: 166.70.13.68 X-SA-Exim-Mail-From: seth@eseth.com Subject: [PATCH v8 1/4] mergetool: add automerge configuration X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Felipe Contreras The purpose of mergetools is to resolve conflicts when git cannot automatically do so. In order to do that git has added markers in the specific areas that need resolving, which the user must manually fix. The tool is supposed to help with that. However, by passing the original BASE, LOCAL, and REMOTE files, many changes without conflict are presented to the user when in fact nothing needs to be done for those. We can fix that by propagating the final version of the file with the automatic merge to all the panes of the mergetool (BASE, LOCAL, and REMOTE), and only make them differ on the places where there are actual conflicts. As most people will want the new behavior, we enable it by default. Users that do not want the new behavior can set the new configuration mergetool.autoMerge to false. See Seth House's blog post [1] for the idea, and the rationale. [1] https://www.eseth.org/2020/mergetools.html Original-idea-by: Seth House Signed-off-by: Felipe Contreras Signed-off-by: Seth House --- Documentation/config/mergetool.txt | 3 +++ git-mergetool.sh | 17 +++++++++++++++++ t/t7610-mergetool.sh | 18 ++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/Documentation/config/mergetool.txt b/Documentation/config/mergetool.txt index 16a27443a3..7ce6d0d3ac 100644 --- a/Documentation/config/mergetool.txt +++ b/Documentation/config/mergetool.txt @@ -61,3 +61,6 @@ mergetool.writeToTemp:: mergetool.prompt:: Prompt before each invocation of the merge resolution program. + +mergetool.autoMerge:: + Remove lines without conflicts from all the files. Defaults to `true`. diff --git a/git-mergetool.sh b/git-mergetool.sh index e3f6d543fb..f4db0cac8d 100755 --- a/git-mergetool.sh +++ b/git-mergetool.sh @@ -239,6 +239,17 @@ checkout_staged_file () { fi } +auto_merge () { + git merge-file --diff3 --marker-size=7 -q -p "$LOCAL" "$BASE" "$REMOTE" >"$DIFF3" + if test -s "$DIFF3" + then + sed -e '/^<<<<<<< /,/^||||||| /d' -e '/^=======\r\?$/,/^>>>>>>> /d' "$DIFF3" >"$BASE" + sed -e '/^||||||| /,/^>>>>>>> /d' -e '/^<<<<<<< /d' "$DIFF3" >"$LOCAL" + sed -e '/^<<<<<<< /,/^=======\r\?$/d' -e '/^>>>>>>> /d' "$DIFF3" >"$REMOTE" + fi + rm -- "$DIFF3" +} + merge_file () { MERGED="$1" @@ -274,6 +285,7 @@ merge_file () { BASE=${BASE##*/} fi + DIFF3="$MERGETOOL_TMPDIR/${BASE}_DIFF3_$$$ext" BACKUP="$MERGETOOL_TMPDIR/${BASE}_BACKUP_$$$ext" LOCAL="$MERGETOOL_TMPDIR/${BASE}_LOCAL_$$$ext" REMOTE="$MERGETOOL_TMPDIR/${BASE}_REMOTE_$$$ext" @@ -322,6 +334,11 @@ merge_file () { checkout_staged_file 2 "$MERGED" "$LOCAL" checkout_staged_file 3 "$MERGED" "$REMOTE" + if test "$(git config --bool mergetool.autoMerge)" != "false" + then + auto_merge + fi + if test -z "$local_mode" || test -z "$remote_mode" then echo "Deleted merge conflict for '$MERGED':" diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh index 70afdd06fa..ccabd04823 100755 --- a/t/t7610-mergetool.sh +++ b/t/t7610-mergetool.sh @@ -828,4 +828,22 @@ test_expect_success 'mergetool -Oorder-file is honored' ' test_cmp expect actual ' +test_expect_success 'mergetool automerge' ' + test_config mergetool.automerge true && + test_when_finished "git reset --hard" && + git checkout -b test${test_count}_b master && + test_write_lines >file1 base "" a && + git commit -a -m "base" && + test_write_lines >file1 base "" c && + git commit -a -m "remote update" && + git checkout -b test${test_count}_a HEAD~ && + test_write_lines >file1 local "" b && + git commit -a -m "local update" && + test_must_fail git merge test${test_count}_b && + yes "" | git mergetool file1 && + test_write_lines >expect local "" c && + test_cmp expect file1 && + git commit -m "test resolved with mergetool" +' + test_done From patchwork Mon Dec 28 04:54:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth House X-Patchwork-Id: 11990841 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9C27C433E9 for ; Mon, 28 Dec 2020 04:55:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A54F422AAD for ; Mon, 28 Dec 2020 04:55:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727719AbgL1Ezp (ORCPT ); Sun, 27 Dec 2020 23:55:45 -0500 Received: from out01.mta.xmission.com ([166.70.13.231]:55996 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727707AbgL1Ezo (ORCPT ); Sun, 27 Dec 2020 23:55:44 -0500 Received: from in02.mta.xmission.com ([166.70.13.52]) by out01.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1ktkYh-008i54-Lc for git@vger.kernel.org; Sun, 27 Dec 2020 21:55:03 -0700 Received: from mta4.zcs.xmission.com ([166.70.13.68]) by in02.mta.xmission.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1ktkYg-00GtzC-6e for git@vger.kernel.org; Sun, 27 Dec 2020 21:55:02 -0700 Received: from localhost (localhost [127.0.0.1]) by mta4.zcs.xmission.com (Postfix) with ESMTP id 1BAB4500516; Sun, 27 Dec 2020 21:55:02 -0700 (MST) X-Amavis-Modified: Mail body modified (using disclaimer) - mta4.zcs.xmission.com Received: from mta4.zcs.xmission.com ([127.0.0.1]) by localhost (mta4.zcs.xmission.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id ozsy1shItbJj; Sun, 27 Dec 2020 21:55:02 -0700 (MST) Received: from localhost.localdomain (unknown [139.60.10.209]) by mta4.zcs.xmission.com (Postfix) with ESMTPSA id D5DC35004F7; Sun, 27 Dec 2020 21:55:00 -0700 (MST) From: Seth House To: git@vger.kernel.org Cc: Seth House Date: Sun, 27 Dec 2020 21:54:25 -0700 Message-Id: <20201228045427.1166911-3-seth@eseth.com> X-Mailer: git-send-email 2.30.0.rc2.4.g8f3eabcc0e In-Reply-To: <20201228045427.1166911-1-seth@eseth.com> References: <20201228004152.522421-1-seth@eseth.com> <20201228045427.1166911-1-seth@eseth.com> MIME-Version: 1.0 X-XM-SPF: eid=1ktkYg-00GtzC-6e;;;mid=<20201228045427.1166911-3-seth@eseth.com>;;;hst=in02.mta.xmission.com;;;ip=166.70.13.68;;;frm=seth@eseth.com;;;spf=none X-SA-Exim-Connect-IP: 166.70.13.68 X-SA-Exim-Mail-From: seth@eseth.com Subject: [PATCH v8 2/4] mergetool: Add per-tool support for the autoMerge flag X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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 --- 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 7ce6d0d3ac..ef147fc118 100644 --- a/Documentation/config/mergetool.txt +++ b/Documentation/config/mergetool.txt @@ -21,6 +21,9 @@ mergetool..trustExitCode:: if the file has been updated, otherwise the user is prompted to indicate the success of the merge. +mergetool..autoMerge:: + Remove lines without conflicts from all the files. Defaults to `true`. + 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 f4db0cac8d..e3c7d78d1d 100755 --- a/git-mergetool.sh +++ b/git-mergetool.sh @@ -334,7 +334,10 @@ merge_file () { checkout_staged_file 2 "$MERGED" "$LOCAL" checkout_staged_file 3 "$MERGED" "$REMOTE" - if test "$(git config --bool mergetool.autoMerge)" != "false" + if test "$( + git config --get --bool "mergetool.$merge_tool.automerge" || + git config --get --bool "mergetool.automerge" || + echo true)" = true then auto_merge fi From patchwork Mon Dec 28 04:54:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth House X-Patchwork-Id: 11990843 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 017CEC433DB for ; Mon, 28 Dec 2020 04:56:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA70A22AB0 for ; Mon, 28 Dec 2020 04:55:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727724AbgL1Ezq (ORCPT ); Sun, 27 Dec 2020 23:55:46 -0500 Received: from out01.mta.xmission.com ([166.70.13.231]:56000 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727707AbgL1Ezq (ORCPT ); Sun, 27 Dec 2020 23:55:46 -0500 Received: from in02.mta.xmission.com ([166.70.13.52]) by out01.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1ktkYi-008i59-SI for git@vger.kernel.org; Sun, 27 Dec 2020 21:55:04 -0700 Received: from mta4.zcs.xmission.com ([166.70.13.68]) by in02.mta.xmission.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1ktkYi-00GtzU-2T for git@vger.kernel.org; Sun, 27 Dec 2020 21:55:04 -0700 Received: from localhost (localhost [127.0.0.1]) by mta4.zcs.xmission.com (Postfix) with ESMTP id 9814C500550; Sun, 27 Dec 2020 21:55:03 -0700 (MST) X-Amavis-Modified: Mail body modified (using disclaimer) - mta4.zcs.xmission.com Received: from mta4.zcs.xmission.com ([127.0.0.1]) by localhost (mta4.zcs.xmission.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id pQh3STKm-mec; Sun, 27 Dec 2020 21:55:03 -0700 (MST) Received: from localhost.localdomain (unknown [139.60.10.209]) by mta4.zcs.xmission.com (Postfix) with ESMTPSA id 711C25004F7; Sun, 27 Dec 2020 21:55:02 -0700 (MST) From: Seth House To: git@vger.kernel.org Cc: Seth House Date: Sun, 27 Dec 2020 21:54:26 -0700 Message-Id: <20201228045427.1166911-4-seth@eseth.com> X-Mailer: git-send-email 2.30.0.rc2.4.g8f3eabcc0e In-Reply-To: <20201228045427.1166911-1-seth@eseth.com> References: <20201228004152.522421-1-seth@eseth.com> <20201228045427.1166911-1-seth@eseth.com> MIME-Version: 1.0 X-XM-SPF: eid=1ktkYi-00GtzU-2T;;;mid=<20201228045427.1166911-4-seth@eseth.com>;;;hst=in02.mta.xmission.com;;;ip=166.70.13.68;;;frm=seth@eseth.com;;;spf=none X-SA-Exim-Connect-IP: 166.70.13.68 X-SA-Exim-Mail-From: seth@eseth.com Subject: [PATCH v8 3/4] mergetool: Break setup_tool out into separate initialization function X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The tool-specific functions are sometimes needed in scope earlier than when run_merge_tool is called. Signed-off-by: Seth House --- Documentation/git-mergetool--lib.txt | 4 ++++ git-difftool--helper.sh | 2 ++ git-mergetool--lib.sh | 7 ++++--- git-mergetool.sh | 2 ++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Documentation/git-mergetool--lib.txt b/Documentation/git-mergetool--lib.txt index 4da9d24096..3e8f59ac0e 100644 --- a/Documentation/git-mergetool--lib.txt +++ b/Documentation/git-mergetool--lib.txt @@ -38,6 +38,10 @@ get_merge_tool_cmd:: get_merge_tool_path:: returns the custom path for a merge tool. +initialize_merge_tool:: + bring merge tool specific functions into scope so they can be used or + overridden. + run_merge_tool:: launches a merge tool given the tool name and a true/false flag to indicate whether a merge base is present. diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh index 46af3e60b7..c47a6d4253 100755 --- a/git-difftool--helper.sh +++ b/git-difftool--helper.sh @@ -61,6 +61,7 @@ launch_merge_tool () { export BASE eval $GIT_DIFFTOOL_EXTCMD '"$LOCAL"' '"$REMOTE"' else + initialize_merge_tool "$merge_tool" run_merge_tool "$merge_tool" fi } @@ -79,6 +80,7 @@ if test -n "$GIT_DIFFTOOL_DIRDIFF" then LOCAL="$1" REMOTE="$2" + initialize_merge_tool "$merge_tool" run_merge_tool "$merge_tool" false else # Launch the merge tool on each path provided by 'git diff' diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh index 7225abd811..e059b3559e 100644 --- a/git-mergetool--lib.sh +++ b/git-mergetool--lib.sh @@ -248,6 +248,10 @@ trust_exit_code () { fi } +initialize_merge_tool () { + # Bring tool-specific functions into scope + setup_tool "$1" || return 1 +} # Entry point for running tools run_merge_tool () { @@ -259,9 +263,6 @@ run_merge_tool () { merge_tool_path=$(get_merge_tool_path "$1") || exit base_present="$2" - # Bring tool-specific functions into scope - setup_tool "$1" || return 1 - if merge_mode then run_merge_cmd "$1" diff --git a/git-mergetool.sh b/git-mergetool.sh index e3c7d78d1d..929192d0f8 100755 --- a/git-mergetool.sh +++ b/git-mergetool.sh @@ -334,6 +334,8 @@ merge_file () { checkout_staged_file 2 "$MERGED" "$LOCAL" checkout_staged_file 3 "$MERGED" "$REMOTE" + initialize_merge_tool "$merge_tool" + if test "$( git config --get --bool "mergetool.$merge_tool.automerge" || git config --get --bool "mergetool.automerge" || From patchwork Mon Dec 28 04:54:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth House X-Patchwork-Id: 11990839 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15E6BC4332B for ; Mon, 28 Dec 2020 04:56:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE8D921D94 for ; Mon, 28 Dec 2020 04:55:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727727AbgL1Ezr (ORCPT ); Sun, 27 Dec 2020 23:55:47 -0500 Received: from out03.mta.xmission.com ([166.70.13.233]:38278 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727720AbgL1Ezr (ORCPT ); Sun, 27 Dec 2020 23:55:47 -0500 Received: from in02.mta.xmission.com ([166.70.13.52]) by out03.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1ktkYj-005P42-HB for git@vger.kernel.org; Sun, 27 Dec 2020 21:55:05 -0700 Received: from mta4.zcs.xmission.com ([166.70.13.68]) by in02.mta.xmission.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1ktkYi-00Gtzl-R3 for git@vger.kernel.org; Sun, 27 Dec 2020 21:55:05 -0700 Received: from localhost (localhost [127.0.0.1]) by mta4.zcs.xmission.com (Postfix) with ESMTP id B895650057A; Sun, 27 Dec 2020 21:55:04 -0700 (MST) X-Amavis-Modified: Mail body modified (using disclaimer) - mta4.zcs.xmission.com Received: from mta4.zcs.xmission.com ([127.0.0.1]) by localhost (mta4.zcs.xmission.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id JNymxk6dHDoG; Sun, 27 Dec 2020 21:55:04 -0700 (MST) Received: from localhost.localdomain (unknown [139.60.10.209]) by mta4.zcs.xmission.com (Postfix) with ESMTPSA id D8AD95004F7; Sun, 27 Dec 2020 21:55:03 -0700 (MST) From: Seth House To: git@vger.kernel.org Cc: Seth House Date: Sun, 27 Dec 2020 21:54:27 -0700 Message-Id: <20201228045427.1166911-5-seth@eseth.com> X-Mailer: git-send-email 2.30.0.rc2.4.g8f3eabcc0e In-Reply-To: <20201228045427.1166911-1-seth@eseth.com> References: <20201228004152.522421-1-seth@eseth.com> <20201228045427.1166911-1-seth@eseth.com> MIME-Version: 1.0 X-XM-SPF: eid=1ktkYi-00Gtzl-R3;;;mid=<20201228045427.1166911-5-seth@eseth.com>;;;hst=in02.mta.xmission.com;;;ip=166.70.13.68;;;frm=seth@eseth.com;;;spf=none X-SA-Exim-Connect-IP: 166.70.13.68 X-SA-Exim-Mail-From: seth@eseth.com Subject: [PATCH v8 4/4] mergetool: Add automerge_enabled tool-specific override function X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Hat-tip to Junio C Hamano for the implementation. Signed-off-by: Seth House --- git-mergetool--lib.sh | 4 ++++ git-mergetool.sh | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh index e059b3559e..5084ceffeb 100644 --- a/git-mergetool--lib.sh +++ b/git-mergetool--lib.sh @@ -164,6 +164,10 @@ setup_tool () { return 1 } + automerge_enabled () { + true + } + translate_merge_tool_path () { echo "$1" } diff --git a/git-mergetool.sh b/git-mergetool.sh index 929192d0f8..a44afd3822 100755 --- a/git-mergetool.sh +++ b/git-mergetool.sh @@ -336,7 +336,7 @@ merge_file () { initialize_merge_tool "$merge_tool" - if test "$( + if automerge_enabled && test "$( git config --get --bool "mergetool.$merge_tool.automerge" || git config --get --bool "mergetool.automerge" || echo true)" = true From patchwork Mon Dec 28 19:29:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth House X-Patchwork-Id: 11991751 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C121C43217 for ; Mon, 28 Dec 2020 23:23:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 48E9322AEC for ; Mon, 28 Dec 2020 23:23:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729823AbgL1Wzh (ORCPT ); Mon, 28 Dec 2020 17:55:37 -0500 Received: from out01.mta.xmission.com ([166.70.13.231]:39074 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729270AbgL1Taj (ORCPT ); Mon, 28 Dec 2020 14:30:39 -0500 Received: from in01.mta.xmission.com ([166.70.13.51]) by out01.mta.xmission.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1ktyDN-00A1eZ-VM; Mon, 28 Dec 2020 12:29:58 -0700 Received: from mta5.zcs.xmission.com ([166.70.13.69]) by in01.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.87) (envelope-from ) id 1ktyDN-0002H1-54; Mon, 28 Dec 2020 12:29:57 -0700 Received: from localhost (localhost [127.0.0.1]) by mta5.zcs.xmission.com (Postfix) with ESMTP id 100BD12802EC; Mon, 28 Dec 2020 12:29:57 -0700 (MST) X-Amavis-Modified: Mail body modified (using disclaimer) - mta5.zcs.xmission.com Received: from mta5.zcs.xmission.com ([127.0.0.1]) by localhost (mta5.zcs.xmission.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id xGBiVSGvrdDC; Mon, 28 Dec 2020 12:29:57 -0700 (MST) Received: from localhost.localdomain (unknown [139.60.10.209]) by mta5.zcs.xmission.com (Postfix) with ESMTPSA id 9FB1712806A8; Mon, 28 Dec 2020 12:29:56 -0700 (MST) From: Seth House To: git@vger.kernel.org Cc: Seth House , Junio C Hamano Date: Mon, 28 Dec 2020 12:29:19 -0700 Message-Id: <20201228192919.1195211-6-seth@eseth.com> X-Mailer: git-send-email 2.30.0.rc2.4.g8f3eabcc0e In-Reply-To: <20201228192919.1195211-1-seth@eseth.com> References: <20201228045427.1166911-1-seth@eseth.com> <20201228192919.1195211-1-seth@eseth.com> MIME-Version: 1.0 X-XM-SPF: eid=1ktyDN-0002H1-54;;;mid=<20201228192919.1195211-6-seth@eseth.com>;;;hst=in01.mta.xmission.com;;;ip=166.70.13.69;;;frm=seth@eseth.com;;;spf=none X-SA-Exim-Connect-IP: 166.70.13.69 X-SA-Exim-Mail-From: seth@eseth.com Subject: [PATCH v9 5/5] mergetool: add automerge_enabled tool-specific override function X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The author or maintainer of a mergetool may optionally elect disable (or enable) the `autoMerge` feature for that mergetool even if the user has chosen differently using the `mergetool.autoMerge` and `mergetool..autoMerge` options. To add a tool-specific override, edit the `mergetools/` shell script for that tool and add an `automerge_enabled` function: automerge_enabled () { return 1 } Disabling may be desirable if the mergetool wants or needs access to the original, unmodified 'LOCAL', 'REMOTE', and 'BASE' versions of the conflicted file. For example: - A tool may use a custom conflict resolution algorithm and prefer to ignore the results of Git's conflict resolution. - A tool may want to visually compare/constrast the version of the file from before the merge (saved to 'LOCAL', 'REMOTE', and 'BASE') with Git's conflict resolution results (saved to 'MERGED'). - A student or researcher working on a new algorithm may want to directly compare the result of that algorithm with the result of Git's algorithm. Helped-by: Junio C Hamano Signed-off-by: Seth House --- git-mergetool--lib.sh | 4 ++++ git-mergetool.sh | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh index e059b3559e..567991abbc 100644 --- a/git-mergetool--lib.sh +++ b/git-mergetool--lib.sh @@ -164,6 +164,10 @@ setup_tool () { return 1 } + automerge_enabled () { + return 0 + } + translate_merge_tool_path () { echo "$1" } diff --git a/git-mergetool.sh b/git-mergetool.sh index 929192d0f8..a44afd3822 100755 --- a/git-mergetool.sh +++ b/git-mergetool.sh @@ -336,7 +336,7 @@ merge_file () { initialize_merge_tool "$merge_tool" - if test "$( + if automerge_enabled && test "$( git config --get --bool "mergetool.$merge_tool.automerge" || git config --get --bool "mergetool.automerge" || echo true)" = true