From patchwork Thu Apr 25 09:54:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10916527 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 4061813B5 for ; Thu, 25 Apr 2019 09:54:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F6872899D for ; Thu, 25 Apr 2019 09:54:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 204B828BA3; Thu, 25 Apr 2019 09:54:51 +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 C014E2899D for ; Thu, 25 Apr 2019 09:54:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728684AbfDYJyt (ORCPT ); Thu, 25 Apr 2019 05:54:49 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:37747 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727536AbfDYJys (ORCPT ); Thu, 25 Apr 2019 05:54:48 -0400 Received: by mail-pf1-f195.google.com with SMTP id g3so743344pfi.4 for ; Thu, 25 Apr 2019 02:54:47 -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=n09q9uk++BnQGLaO7ISBMXJQYpqeJfefi3fy5n5GfUI=; b=WIuzBHQXZMOEM+qpSWcZbp+xBDmJEJUUbVL1v6GBoKEZDQQteno/YNWwkIFMm7kA/o e8nEfTMlbf7im+yy+KiXrgrF8hMMMvUSpGaTkcRkBcleLE/jC/4T2M2vBB7yRC/4MxVd DANK6jF4qzRkUZVRgWri0JkQoBvPL/oFBlYnRlB73f+ZtOXhDyokzv40z6uMwDFxNZeD Div3Vs53fKGHyLRaXooW6Dga41sQ3i+6IWj7aidcZB6ORTg/LCqHUz/651tMcr/3FPg7 Lw5BMXGZ4cQETS/8S1+CZsUZT7WQb54pw7DDdxZcBzO5/ucZkA2jGUpWopStROurLVfs rwIw== 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=n09q9uk++BnQGLaO7ISBMXJQYpqeJfefi3fy5n5GfUI=; b=Y86VT0Nkw4R5ZV+IXa9lUBo1N8dMwLQSdCEGXv5StUlhTf9hdkxiYmmsO1wrU5QwFL FMWF94DrdBclwYzhZo889jba0Mk1OZ50GmHnW6nDpTP7yW27v+eXDRzEeKRtPJTE0g/r L6Ag4zUy5aXZypBMTD+L86C4JSVRlDtDPP/+URZC0c+RRxBwkYs/7xh1hiIdE6MLgPWw ZIrS8M3illdKoR96SLz3iTAS9RKSww6/hnpMXzvHt2LWFaQ5rA1m1r/aW0XkiLiueP8C XkR74mKClv+Wls24KAcGPaIClwJUJg6tK4JfqwqaB9C1TS3DMDcjhLgbMw7OngZ12msu NgcA== X-Gm-Message-State: APjAAAWGGCOnJD7e1z+ZH8C52b02VsqwapiFi9vdHXm2jYMUDMUzEBzk yjh4AfdbdgNRjbYICzcjYEP1Xrl2 X-Google-Smtp-Source: APXvYqwWkh1wmJHMUrg+Jbx0LiSI/a3neXt/mjZZnHZAFSVV/DQksOd44k0bQi7chex6iSRBHlNG/w== X-Received: by 2002:aa7:8083:: with SMTP id v3mr40253322pff.135.1556186087227; Thu, 25 Apr 2019 02:54:47 -0700 (PDT) Received: from archbookpro.localdomain (c-73-222-73-77.hsd1.ca.comcast.net. [73.222.73.77]) by smtp.gmail.com with ESMTPSA id r145sm46805536pgr.84.2019.04.25.02.54.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Apr 2019 02:54:46 -0700 (PDT) Date: Thu, 25 Apr 2019 02:54:44 -0700 From: Denton Liu To: Git Mailing List Cc: Johannes Schindelin , David Aguilar , Jeff Hostetler , Eric Sunshine , Junio C Hamano Subject: [PATCH v4 5/6] difftool: make --gui, --tool and --extcmd mutually exclusive Message-ID: <7d7c936cd3dabe95c2b26d46c5b5bb980c26586b.1556185345.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.4 (2019-03-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 git-difftool, these options specify which tool to ultimately run. As a result, they are logically conflicting. Explicitly disallow these options from being used together. Signed-off-by: Denton Liu --- builtin/difftool.c | 3 +++ t/t7800-difftool.sh | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/builtin/difftool.c b/builtin/difftool.c index a3ea60ea71..65bba90338 100644 --- a/builtin/difftool.c +++ b/builtin/difftool.c @@ -731,6 +731,9 @@ int cmd_difftool(int argc, const char **argv, const char *prefix) setenv(GIT_DIR_ENVIRONMENT, absolute_path(get_git_dir()), 1); setenv(GIT_WORK_TREE_ENVIRONMENT, absolute_path(get_git_work_tree()), 1); + 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); else if (difftool_cmd) { diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh index bb9a7f4ff9..107f31213d 100755 --- a/t/t7800-difftool.sh +++ b/t/t7800-difftool.sh @@ -705,4 +705,12 @@ test_expect_success SYMLINKS 'difftool --dir-diff handles modified symlinks' ' test_cmp expect actual ' +test_expect_success 'difftool --gui, --tool and --extcmd are exclusive' ' + difftool_test_setup && + test_must_fail git difftool --gui --tool=test-tool && + test_must_fail git difftool --gui --extcmd=cat && + test_must_fail git difftool --tool=test-tool --extcmd=cat && + test_must_fail git difftool --gui --tool=test-tool --extcmd=cat +' + test_done