From patchwork Wed Oct 24 02:25: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: 10654067 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 133BD14BD for ; Wed, 24 Oct 2018 02:51:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E609C2A584 for ; Wed, 24 Oct 2018 02:51:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D9A322A59D; Wed, 24 Oct 2018 02:51:55 +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 354A82A599 for ; Wed, 24 Oct 2018 02:51:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726414AbeJXLRy (ORCPT ); Wed, 24 Oct 2018 07:17:54 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:51925 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725896AbeJXLRy (ORCPT ); Wed, 24 Oct 2018 07:17:54 -0400 Received: by mail-it1-f194.google.com with SMTP id 74-v6so4409960itw.1 for ; Tue, 23 Oct 2018 19:51:52 -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:mime-version:content-disposition :user-agent; bh=ByjuDItGVXxhkW0vuFaMAvuq6aLC/fuxqQ9HjuxV+zc=; b=AFswe2RA1apM+Ir4ChVv04/PjqFeDFm2tqFOGSeRrYGqLDQoo186imqpUNozB6WpwG zDMsobsOxugxpD3UFM92DSJ3ewDGkFb+z/SGglJGDJt3OUlVcQ1ZIlyiapfGHGLAnFzh qHiOrDuM5SwEH2lI5iQLaSdeVZvN0CRIs1UyMqE5c2GLYfGDyprLYZMaZCp5QhLIRUZO Ts3va5MRHkSNQFktfSBMTMI2O2jAhi00Bb3dWl8E1i4x7eiXPxy59XTB3iJqiQIufeVO 375fgYvei5+xSR4YBi2djNqc3EcS/uNqp2wEDnpD/x34XPdPSqybUPbZhwnPtsNTOw+6 Fy9g== 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:mime-version :content-disposition:user-agent; bh=ByjuDItGVXxhkW0vuFaMAvuq6aLC/fuxqQ9HjuxV+zc=; b=EvnejQnaNKvTZ3ipog8oWCqix6GyqRK2VVbjtWvBSqFVk7DglKMvTTdpUV2a1sWwxp hr52wyrgq8x7pYv2v1JtGvJajxG9aGawJEr1CElntFr6urWgFdKr59Xq28LIZMeew6TZ Kk/Amx5lY26I2spxOEJ3kQl4db9MLkWgO2lkumgqW3GLLVVxlSzB/9Ll2uzqmHcTboru Ld9s+nT3wSOarDnTUTs9pUd/TejTCEW2mjggTw1Q9ayKMO5norhxXRJJrkNPXABIJ1Yz i+dT8PySQFuNg92xYaIK0LY4EV88wzoWm/15r+gm/BlzkUhnx2UyPiTds0/SZyZmZRZQ ltQw== X-Gm-Message-State: AGRZ1gIjXfXKizGuirX/wn5Ym8Q7ai8MLBf/ayu/QOxmv1ZVjMNj/QAU tQRxk78snYsDZe/9VQnfocZMWPP/ X-Google-Smtp-Source: AJdET5ey0z3MdynbeyBkLY3JtRUpI2vyV9iV91xT6tUvhsc1UCMgZDlFUaOfN5EMH4bmBGEAMi1wCw== X-Received: by 2002:a02:b422:: with SMTP id i31-v6mr575243jaj.40.1540347902999; Tue, 23 Oct 2018 19:25:02 -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 64-v6sm1494618itm.29.2018.10.23.19.25.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Oct 2018 19:25:02 -0700 (PDT) Date: Tue, 23 Oct 2018 22:25: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 Subject: [PATCH 1/2] mergetool: Accept -g/--[no-]gui as arguments Message-ID: <20181024022500.GA29011@archbookpro.localdomain> MIME-Version: 1.0 Content-Disposition: inline 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..e317ae003 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 [ "$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 02:25:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10654051 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 223AE13A9 for ; Wed, 24 Oct 2018 02:47:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 042E12A1B8 for ; Wed, 24 Oct 2018 02:47:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC1D72A1F6; Wed, 24 Oct 2018 02:47:49 +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 A3DD32A1B8 for ; Wed, 24 Oct 2018 02:47:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726543AbeJXLNr (ORCPT ); Wed, 24 Oct 2018 07:13:47 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:42950 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725266AbeJXLNq (ORCPT ); Wed, 24 Oct 2018 07:13:46 -0400 Received: by mail-io1-f67.google.com with SMTP id n18-v6so2201973ioa.9 for ; Tue, 23 Oct 2018 19:47:46 -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:mime-version:content-disposition :user-agent; bh=rbzjfi72SOlcqcYe+gXXD6YoDqn6ghOmoLZ60dRN0zI=; b=nTsjZ/sTYRfaQjVFARSmN4fkEO2zvjis2BJhJekT3c6f8+/l88mmMuJ6r8pLI1AcAw m7Qt68qZZGVXLEoIgviYNB8WlIOAQwu6g5xxKJhr2rHvASWCoMGZ+hzxA4OyIqHLeTb+ eZtfEALYnyZ1NbmqUJn/4yxmxQxbheFovhAvBRlzxRuJcifqH2GUOHG5HSDNgQfUwijP blU9ATteB8LrV/ZC9vSW4/lr7GF2RuKciL/HUkP9Gd7aC+MLBQCdTGbpY8TZsGQ3AZWx lrxsRO+HF0PJeWmGy5I3PH2z27/rMJ8o8rEI9YKzKiLBbi0SojQi6naoTJJRd73nihIf dxbA== 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:mime-version :content-disposition:user-agent; bh=rbzjfi72SOlcqcYe+gXXD6YoDqn6ghOmoLZ60dRN0zI=; b=F41QO6s+9Vv8KAtBVpPx/I0bO+hHZ74oEvGB/fjC4lugmp+1t/2Z/P3UYuwe9GvP5d mxtEmtdWgHqeu+a0HgSdIHyCPPlZGjhmuX4IHuATyGxJSEXjgF1eLbBjQRdiNlki8482 YsSvuo6BI/4Pum5FCkvVaFTtnQPD8OFCJTz8WahV+HMQWgh66o7ZSoXW2ykgSU8Qdv9U Wtli21bnWQXlab4bsDskYj8Wdc6DiP5VXxAhjbwUqPHzaqV6j126PXjhYsGX2GEVlJHC 0IdZ96fEmdoTpzYEXU5HPGqR6KHhYG9Q0+5WiMa7jhYGsKA42xM88y13s57K9XgsfMAx AOoA== X-Gm-Message-State: AGRZ1gKuOgt3nzP4XUObQc7BprlCbnzgnaBS0/8reHaHLzZKAcfH4Gpe eQ/b6iD1tWM6SGak055KjS8H0zkQ X-Google-Smtp-Source: AJdET5dg1kNGg91oN9S6yZ00BumHgV3Ce0valMPM9cNmJX6BuVzSyCeMuZhgkuCs3ZWw6ZYE1/dvLA== X-Received: by 2002:a6b:b417:: with SMTP id d23-v6mr13188416iof.227.1540347914393; Tue, 23 Oct 2018 19:25:14 -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 c26-v6sm1824082itd.18.2018.10.23.19.25.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Oct 2018 19:25:13 -0700 (PDT) Date: Tue, 23 Oct 2018 22:25:11 -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 Subject: [PATCH 2/2] completion: Support `git mergetool --[no-]gui` Message-ID: <20181024022511.GA29050@archbookpro.localdomain> MIME-Version: 1.0 Content-Disposition: inline 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