From patchwork Wed Oct 24 05:58:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10654177 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 12E1B13B5 for ; Wed, 24 Oct 2018 05:58:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA4A42A625 for ; Wed, 24 Oct 2018 05:58:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAFFD2A62F; Wed, 24 Oct 2018 05:58:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 585132A625 for ; Wed, 24 Oct 2018 05:58:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726423AbeJXOYk (ORCPT ); Wed, 24 Oct 2018 10:24:40 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:51638 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726080AbeJXOYk (ORCPT ); Wed, 24 Oct 2018 10:24:40 -0400 Received: by mail-it1-f194.google.com with SMTP id 74-v6so4745843itw.1 for ; Tue, 23 Oct 2018 22:58:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=tbcRjHfosrFlcL1zECmO1lFiSIimxlWzQBo+568L0Qk=; b=Q8e0eg3drO/Ipc23c5hm7Rs20BWuMEZOrhMwkjas2CDLt6SAjsHQH7Z7xRsYubRnwT YQtpXwH9usC4uElOol7y7GjK7xjEbuhG4HvUcVWOX1EDixS6hX2UN0rarw/QIuAiqIdb 2TgGjP11ojnw+YvAWg/IUsjBgjAohb6AzGX31sGKOWgOh4+pj3AT2VYpZi8qDHksXR6H r0YFiLZQoo1gZLaxb5xNfWNdIkFNEWu6Dm/L2U8iCsBD3HmmpHshgLxlezpZFMmnlQsd gDew88Rk7F82VSrtoHc578UZQ+GKygZEO1s41y4KTpZv2zXgVZjTSEOg/ChO0roM9O2j q6LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=tbcRjHfosrFlcL1zECmO1lFiSIimxlWzQBo+568L0Qk=; b=Kx6Kn9YW6SLr/czBrvtSuDHbZqwcG8oazyQi7NIFGTk5PxLycYD4pIO9wrQzrRP2y5 gLuFG8dh2FkGUpdh6MmSQW7z34thjuRPdw5VWXnWOET+SQEiUlkY1ZwdWFfTDoTpp85C lux8ReHcA55mviGgZ5VKiq859yJCzyJ46PaNnvr18kp9qshYeYGBRZNRybg65JJI1fg9 AiMqH+Wo3toLdweFPCWuQx18WdiXwn4uyR/NjtXXKhgCojpoccsIlovoa6rrx1s3ugVA 9Dy4bXmZBidnJByOKWBmCcuh9nyzSpEV982hs0569RuyXnx5R+yiXNlPP8k1Vdvn5QhO rKMQ== X-Gm-Message-State: AGRZ1gIEUTkO4H8mQ5XgnJ7aooYOpqZqzope8A/KxzydG6OuFGnD/2ov ImzaowGFet94SEhgHrWc66WL51qr X-Google-Smtp-Source: AJdET5ctRTHnug+83AUO0GdguxC6YQ+knByzpTiIyy62gtselBQlZVoP5eFOkqYMcppGHWYtoCiGew== X-Received: by 2002:a24:393:: with SMTP id e141-v6mr661722ite.153.1540360683018; Tue, 23 Oct 2018 22:58:03 -0700 (PDT) Received: from archbookpro.localdomain (ktnron0919w-lp140-01-76-68-143-166.dsl.bell.ca. [76.68.143.166]) by smtp.gmail.com with ESMTPSA id o194-v6sm2048906ito.11.2018.10.23.22.58.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Oct 2018 22:58:02 -0700 (PDT) Date: Wed, 24 Oct 2018 01:58:00 -0400 From: Denton Liu To: git@vger.kernel.org Cc: liu.denton@gmail.com, anmolmago@gmail.com, briankyho@gmail.com, david.lu97@outlook.com, shirui.wang@hotmail.com, davvid@gmail.com, gitster@pobox.com Subject: [PATCH v2 1/2] mergetool: accept -g/--[no-]gui as arguments Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In line with how difftool accepts a -g/--[no-]gui option, make mergetool accept the same option in order to use the `merge.guitool` variable to find the default mergetool instead of `merge.tool`. Signed-off-by: Denton Liu Signed-off-by: Anmol Mago Signed-off-by: Brian Ho Signed-off-by: David Lu Signed-off-by: Ryan Wang Acked-by: David Aguilar --- Documentation/git-mergetool.txt | 11 +++++++++++ git-mergetool--lib.sh | 16 +++++++++++----- git-mergetool.sh | 11 +++++++++-- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt index 3622d6648..0c7975a05 100644 --- a/Documentation/git-mergetool.txt +++ b/Documentation/git-mergetool.txt @@ -79,6 +79,17 @@ success of the resolution after the custom tool has exited. Prompt before each invocation of the merge resolution program to give the user a chance to skip the path. +-g:: +--gui:: + When 'git-mergetool' is invoked with the `-g` or `--gui` option + the default merge tool will be read from the configured + `merge.guitool` variable instead of `merge.tool`. + +--no-gui:: + This overrides a previous `-g` or `--gui` setting and reads the + default merge tool will be read from the configured `merge.tool` + variable. + -O:: Process files in the order specified in the , which has one shell glob pattern per line. diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh index 9a8b97a2a..83bf52494 100644 --- a/git-mergetool--lib.sh +++ b/git-mergetool--lib.sh @@ -350,17 +350,23 @@ guess_merge_tool () { } get_configured_merge_tool () { - # Diff mode first tries diff.tool and falls back to merge.tool. - # Merge mode only checks merge.tool + # If first argument is true, find the guitool instead + if test "$1" = true + then + gui_prefix=gui + fi + + # Diff mode first tries diff.(gui)tool and falls back to merge.(gui)tool. + # Merge mode only checks merge.(gui)tool if diff_mode then - merge_tool=$(git config diff.tool || git config merge.tool) + merge_tool=$(git config diff.${gui_prefix}tool || git config merge.${gui_prefix}tool) else - merge_tool=$(git config merge.tool) + merge_tool=$(git config merge.${gui_prefix}tool) fi if test -n "$merge_tool" && ! valid_tool "$merge_tool" then - echo >&2 "git config option $TOOL_MODE.tool set to unknown tool: $merge_tool" + echo >&2 "git config option $TOOL_MODE.${gui_prefix}tool set to unknown tool: $merge_tool" echo >&2 "Resetting to default..." return 1 fi diff --git a/git-mergetool.sh b/git-mergetool.sh index d07c7f387..01b9ad59b 100755 --- a/git-mergetool.sh +++ b/git-mergetool.sh @@ -9,7 +9,7 @@ # at the discretion of Junio C Hamano. # -USAGE='[--tool=tool] [--tool-help] [-y|--no-prompt|--prompt] [-O] [file to merge] ...' +USAGE='[--tool=tool] [--tool-help] [-y|--no-prompt|--prompt] [-g|--gui|--no-gui] [-O] [file to merge] ...' SUBDIRECTORY_OK=Yes NONGIT_OK=Yes OPTIONS_SPEC= @@ -389,6 +389,7 @@ print_noop_and_exit () { main () { prompt=$(git config --bool mergetool.prompt) + gui_tool=false guessed_merge_tool=false orderfile= @@ -414,6 +415,12 @@ main () { shift ;; esac ;; + --no-gui) + gui_tool=false + ;; + -g|--gui) + gui_tool=true + ;; -y|--no-prompt) prompt=false ;; @@ -443,7 +450,7 @@ main () { if test -z "$merge_tool" then # Check if a merge tool has been configured - merge_tool=$(get_configured_merge_tool) + merge_tool=$(get_configured_merge_tool $gui_tool) # Try to guess an appropriate merge tool if no tool has been set. if test -z "$merge_tool" then From patchwork Wed Oct 24 05:58:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10654179 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AFD2F13A4 for ; Wed, 24 Oct 2018 05:58:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB80928752 for ; Wed, 24 Oct 2018 05:58:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 99B102A62F; Wed, 24 Oct 2018 05:58:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 930C52A625 for ; Wed, 24 Oct 2018 05:58:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726433AbeJXOYx (ORCPT ); Wed, 24 Oct 2018 10:24:53 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:44710 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726240AbeJXOYx (ORCPT ); Wed, 24 Oct 2018 10:24:53 -0400 Received: by mail-io1-f65.google.com with SMTP id c6-v6so1692464iob.11 for ; Tue, 23 Oct 2018 22:58:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=rbzjfi72SOlcqcYe+gXXD6YoDqn6ghOmoLZ60dRN0zI=; b=YkNmMi97CEjJRQYei+9Wf/jTrMHWxOtXQd+PyTrPPhhEstpVOMLUd/dVmbtFmYFk8U gCbX1+sFN1DXtGEEpW3g16jVi30fzsjGd1rpzO+RHTAPcmqjxzbOvb797UqlK6tXkXQ+ wDYZ4gxViBM/+AALmc2kQ37zqM1zCMHWNnREa/QPRR2xzk3q05HNLn6Ze6zpxH///DFr oZT0pqKXdxE1hIw4cE67xvmi/A4+UITc7akroCC+E7KY/O3ysoX/Em5ddgLEQw9IkNu9 3yfKuD6VPFHE6Mw1vYPB4m4C66T/JxqPmZAyBhxQhLFomHW2KrKI7EGEeeD8RhSnAARk SKHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=rbzjfi72SOlcqcYe+gXXD6YoDqn6ghOmoLZ60dRN0zI=; b=GNd5U7EUPVD+zB/hu97uFgdxV2Mw2bPPLAAYxx2hJEKFAStpYyHYCqqc1ZsnmSMt3h GxfNuK8DggHkVhSgeNymS10P3Wtl3Rawzb0I+b+KtONA/8G8KJOf08gWVka5zGZ7PITC WUbIZVrYs07SIqY5QJ5k6kcA7hayvjZ931wD3740T4ULZgxTtH25NcY2klf+oJ6/ku1V eNS7MAV24CWUpGzQhqB2Ioot9p5DB8/odNOOTOQUdISxiaKJ8Anu85zTPZGVpmAZ3gdt BsejCU6ugduQrxGYoTSWXVbIZtqBnPuerd2fy+ZuOC/lRGm8RwOZ7q1F37Nq2pfJ2C1p kwBg== X-Gm-Message-State: AGRZ1gKqQvqxs9Sw8/SYJn5wzgs1SbYOf7NSG6vLDgqyhmhnINVDD8fZ BF1ZhHXAw1M89r3ZeNLDUJCtFEmu X-Google-Smtp-Source: AJdET5dGetzkSK7dG1zV5ClT7053w3zESCrIT5mxScXo3TGeN9/FfBNh3y/1q1d2kubtPj08aq3+5A== X-Received: by 2002:a6b:bf43:: with SMTP id p64-v6mr12373018iof.41.1540360696339; Tue, 23 Oct 2018 22:58:16 -0700 (PDT) Received: from archbookpro.localdomain (ktnron0919w-lp140-01-76-68-143-166.dsl.bell.ca. [76.68.143.166]) by smtp.gmail.com with ESMTPSA id x21-v6sm1824062ita.6.2018.10.23.22.58.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Oct 2018 22:58:15 -0700 (PDT) Date: Wed, 24 Oct 2018 01:58:14 -0400 From: Denton Liu To: git@vger.kernel.org Cc: liu.denton@gmail.com, anmolmago@gmail.com, briankyho@gmail.com, david.lu97@outlook.com, shirui.wang@hotmail.com, davvid@gmail.com, gitster@pobox.com Subject: [PATCH v2 2/2] completion: support `git mergetool --[no-]gui` Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Denton Liu Signed-off-by: Anmol Mago Signed-off-by: Brian Ho Signed-off-by: David Lu Signed-off-by: Ryan Wang --- contrib/completion/git-completion.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index db7fd87b6..a45b4a050 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1833,7 +1833,7 @@ _git_mergetool () return ;; --*) - __gitcomp "--tool= --prompt --no-prompt" + __gitcomp "--tool= --prompt --no-prompt --gui --no-gui" return ;; esac