From patchwork Wed Apr 24 22:47:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10915869 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 DC33313B5 for ; Wed, 24 Apr 2019 22:47:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9B0728ABC for ; Wed, 24 Apr 2019 22:47:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE3F928BE4; Wed, 24 Apr 2019 22:47:09 +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 52C4428ABC for ; Wed, 24 Apr 2019 22:47:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726829AbfDXWrI (ORCPT ); Wed, 24 Apr 2019 18:47:08 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:41153 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726984AbfDXWrH (ORCPT ); Wed, 24 Apr 2019 18:47:07 -0400 Received: by mail-pg1-f196.google.com with SMTP id f6so10110246pgs.8 for ; Wed, 24 Apr 2019 15:47:06 -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=sw448NwAPnuHRAOZn8IVLJkytIV16ZWjwj1QCC6oBng=; b=uBFGGac6IZZxpeiZaNAX59rdH5KXpJ7w6xnKvKWdg0ryasIsHjaKoqKvtVD6ijj0lf T4Gb6BE8vbEW8HroHR+c3vntpFmZwQzMjWTmAS1P3ErTkUGCzFagSueaHyn6/JYVA1qO 15FvhN7b0EepmUBLPUgSjo85xIs+4C3TQlw4Nz9nZeGiqs+ZkkRaQMtTDRUoB/NNUrwV +uDuLeT9vND6eVN8KAuOaSas0MmVlFISMqhP2nncmvBkS6SrI9AMDcV1iCBeM0a04Us9 4wXajzjeWcEzn0hJ/cOdzMvpZS7BACgHTAesWVCqwhw9z2WrWjt23nx69KNX/50GV3K7 nkcA== 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=sw448NwAPnuHRAOZn8IVLJkytIV16ZWjwj1QCC6oBng=; b=ahcPQwhTB2T7sksuKr5c1bhPQuA/FkY7AGkXWgZizZLAjTdpQUHwe+wIM3pNiQLHGc W6OiW4ISztwYuFK7aexGwun43UQcaHD3BLQSshF0fyP/omlu5WPAHR3UIHxh4A8Ad7Xg RzOWOMHXfuG/tv5OTLWIPMlPSkqoweTp9gqqxXynArAzg64amCnCXF5CDwRfRj4t9uj7 b7ShXOo/ZU84WxvTuqW2qu9vxlFPpaZsDuDe8gnXJ7Fm3+nfnfLcCehNBt3aNPOBHSr3 c/O13O5fB2zpn60ttIqEaIXotSGOdOpUapU6xdsZODzOcFkE0w/liVGtgr8N3klIXXKD BOBg== X-Gm-Message-State: APjAAAWITdaWCEiFvOtBS12Aq33pcicv29b3x4Y5Tp3nNN1x7za1S5yi NjRQCdHyVDedz/KsEuYC2QzEDn7Z X-Google-Smtp-Source: APXvYqwXa1wc2SF0E7ExABgcam9X3U8AYJaeRE2Bx1hw1MCmymXAGbMtnW2QWztzvkvF/R3YT++6xA== X-Received: by 2002:a65:6107:: with SMTP id z7mr32957163pgu.313.1556146026036; Wed, 24 Apr 2019 15:47:06 -0700 (PDT) Received: from dev-l ([149.28.200.39]) by smtp.gmail.com with ESMTPSA id g64sm38062305pfg.13.2019.04.24.15.47.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Apr 2019 15:47:05 -0700 (PDT) Date: Wed, 24 Apr 2019 15:47:04 -0700 From: Denton Liu To: Git Mailing List Cc: Johannes Schindelin , David Aguilar , Jeff Hostetler , Eric Sunshine , Junio C Hamano Subject: [PATCH v3 6/6] difftool: fallback on merge.guitool Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In git-difftool.txt, it says 'git difftool' falls back to 'git mergetool' config variables when the difftool equivalents have not been defined. However, when `diff.guitool` is missing, it doesn't fallback to anything. Make git-difftool fallback to `merge.guitool` when `diff.guitool` is missing. Signed-off-by: Denton Liu --- Documentation/git-difftool.txt | 4 +++- builtin/difftool.c | 10 ++-------- t/t7800-difftool.sh | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Documentation/git-difftool.txt b/Documentation/git-difftool.txt index 96c26e6aa8..484c485fd0 100644 --- a/Documentation/git-difftool.txt +++ b/Documentation/git-difftool.txt @@ -90,7 +90,9 @@ instead. `--no-symlinks` is the default on Windows. When 'git-difftool' is invoked with the `-g` or `--gui` option the default diff tool will be read from the configured `diff.guitool` variable instead of `diff.tool`. The `--no-gui` - option can be used to override this setting. + option can be used to override this setting. If `diff.guitool` + is not set, we will fallback in the order of `merge.guitool`, + `diff.tool`, `merge.tool` until a tool is found. --[no-]trust-exit-code:: 'git-difftool' invokes a diff tool individually on each file. diff --git a/builtin/difftool.c b/builtin/difftool.c index 65bba90338..10660639c0 100644 --- a/builtin/difftool.c +++ b/builtin/difftool.c @@ -24,7 +24,6 @@ #include "object-store.h" #include "dir.h" -static char *diff_gui_tool; static int trust_exit_code; static const char *const builtin_difftool_usage[] = { @@ -34,11 +33,6 @@ static const char *const builtin_difftool_usage[] = { static int difftool_config(const char *var, const char *value, void *cb) { - if (!strcmp(var, "diff.guitool")) { - diff_gui_tool = xstrdup(value); - return 0; - } - if (!strcmp(var, "difftool.trustexitcode")) { trust_exit_code = git_config_bool(var, value); return 0; @@ -734,8 +728,8 @@ int cmd_difftool(int argc, const char **argv, const char *prefix) if (use_gui_tool + !!difftool_cmd + !!extcmd > 1) die(_("--gui, --tool and --extcmd are mutually exclusive")); - if (use_gui_tool && diff_gui_tool && *diff_gui_tool) - setenv("GIT_DIFF_TOOL", diff_gui_tool, 1); + if (use_gui_tool) + setenv("GIT_MERGETOOL_GUI", "true", 1); else if (difftool_cmd) { if (*difftool_cmd) setenv("GIT_DIFF_TOOL", difftool_cmd, 1); diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh index 107f31213d..ae90701a12 100755 --- a/t/t7800-difftool.sh +++ b/t/t7800-difftool.sh @@ -279,11 +279,27 @@ test_expect_success 'difftool + mergetool config variables' ' echo branch >expect && git difftool --no-prompt branch >actual && test_cmp expect actual && + git difftool --gui --no-prompt branch >actual && + test_cmp expect actual && # set merge.tool to something bogus, diff.tool to test-tool test_config merge.tool bogus-tool && test_config diff.tool test-tool && git difftool --no-prompt branch >actual && + test_cmp expect actual && + git difftool --gui --no-prompt branch >actual && + test_cmp expect actual && + + # set merge.tool, diff.tool to something bogus, merge.guitool to test-tool + test_config diff.tool bogus-tool && + test_config merge.guitool test-tool && + git difftool --gui --no-prompt branch >actual && + test_cmp expect actual && + + # set merge.tool, diff.tool, merge.guitool to something bogus, diff.guitool to test-tool + test_config merge.guitool bogus-tool && + test_config diff.guitool test-tool && + git difftool --gui --no-prompt branch >actual && test_cmp expect actual '