From patchwork Thu Apr 25 09:54:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10916519 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 43EB813B5 for ; Thu, 25 Apr 2019 09:54:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30D9328BA3 for ; Thu, 25 Apr 2019 09:54:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24CAF28C21; Thu, 25 Apr 2019 09:54:40 +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 335F128BA3 for ; Thu, 25 Apr 2019 09:54:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728579AbfDYJyi (ORCPT ); Thu, 25 Apr 2019 05:54:38 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:38742 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728324AbfDYJyh (ORCPT ); Thu, 25 Apr 2019 05:54:37 -0400 Received: by mail-pl1-f194.google.com with SMTP id f36so10820885plb.5 for ; Thu, 25 Apr 2019 02:54:36 -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=JI/Lia72G0FNL112c0dOM2shPHSe/tqNtZcRPBwe5rk=; b=jqBqjEUe+6YIerq+sRjAk6uF3FcHCYF+a56OQ9ndGqc6qIXxcFNnrVG+Q4g6STxUv/ TkbQqY8r4MeLnqPmzrGUYEAyLoz17TbhkjVMirlUdw1qdoewIhHVj3HjjPdQIFJtFcMF M3i4DYNseQOwL4mAAHwG0GzPqkX1aT/kKvwo0qy/fLRubB/U5rEvOWDTjQPaChKe0rqh fKlGcMfDwjAFA0W4duJc/j1m3k8FKAey5f6qRubXH/Zyk4iEO7o7+8qFMZ0qR+SjD7Kr rZC4/OuKsjV0kY9zB6WCeWBxkJS325MSuGJiRSoXaviNQ2sGihJmvt1F3N79F8ePxvof +BqQ== 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=JI/Lia72G0FNL112c0dOM2shPHSe/tqNtZcRPBwe5rk=; b=qpK/QmzsGvA5rJEMl+S0lPu3YvcBZ3Gg1v+b6LbwrOcBIyeUxzYhxvWjvdnhipMDfx C9EEdaTpS9fZT2tz7HaBeY7Tne/15/yhjXLZoaSlMif829XB+pfzo5vdJtwb8rm1xaY7 cyDge2HYj+sfem3p31aI7GGHUF7WEobzdIwMHtmXqiECrdXjPwDfoM6xFhTuvD6BbxUW ai9T1xkq/UkWH1fghCtMn5Mn4S5+G5yRNEE6ihLY1Ux+jbh7sXwTkTja6E+CrXMmeEYF Bc/mPWpSgwO7cRGtYLeZhNjLtD/d7nuz3RgTC1bxhMkJZwoUD120iN55AtOZPSs3akBp aQXg== X-Gm-Message-State: APjAAAUTisApYuunl/NU1SmuTjoFOpLjzact+8rkTN1I6+37LbQG0FUw AadPGcDOS3oBJqonCbN6vSfLkPuV X-Google-Smtp-Source: APXvYqzL8l+gd2u3Ok+07AZgeYnYKQnZRJhfSEWAqq0MKIWRykeuz04JtlIrh8LpcDN7q2yj+PkCkA== X-Received: by 2002:a17:902:b597:: with SMTP id a23mr38285210pls.284.1556186075998; Thu, 25 Apr 2019 02:54:35 -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 f71sm39073544pfc.109.2019.04.25.02.54.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Apr 2019 02:54:35 -0700 (PDT) Date: Thu, 25 Apr 2019 02:54:33 -0700 From: Denton Liu To: Git Mailing List Cc: Johannes Schindelin , David Aguilar , Jeff Hostetler , Eric Sunshine , Junio C Hamano Subject: [PATCH v4 1/6] t7610: unsuppress output Message-ID: <9f9922cab341396a846edc2f52342c59d294379a.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 The output for commands used to be suppressed by redirecting both stdout and stderr to /dev/null. However, this should not happen since the output is useful for debugging and, without the "-v" flag, test scripts don't output anyway. Unsuppress the output by removing the redirections to /dev/null. Signed-off-by: Denton Liu --- t/t7610-mergetool.sh | 122 +++++++++++++++++++++---------------------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh index a9fb971615..69711487dd 100755 --- a/t/t7610-mergetool.sh +++ b/t/t7610-mergetool.sh @@ -130,14 +130,14 @@ test_expect_success 'custom mergetool' ' test_when_finished "git reset --hard" && git checkout -b test$test_count branch1 && git submodule update -N && - test_must_fail git merge master >/dev/null 2>&1 && - ( yes "" | git mergetool both >/dev/null 2>&1 ) && + test_must_fail git merge master && + ( yes "" | git mergetool both ) && ( yes "" | git mergetool file1 file1 ) && - ( yes "" | git mergetool file2 "spaced name" >/dev/null 2>&1 ) && - ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) && - ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) && - ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) && - ( yes "l" | git mergetool submod >/dev/null 2>&1 ) && + ( yes "" | git mergetool file2 "spaced name" ) && + ( yes "" | git mergetool subdir/file3 ) && + ( yes "d" | git mergetool file11 ) && + ( yes "d" | git mergetool file12 ) && + ( yes "l" | git mergetool submod ) && test "$(cat file1)" = "master updated" && test "$(cat file2)" = "master new" && test "$(cat subdir/file3)" = "master new sub" && @@ -153,15 +153,15 @@ test_expect_success 'mergetool crlf' ' # test_when_finished is LIFO.) test_config core.autocrlf true && git checkout -b test$test_count branch1 && - test_must_fail git merge master >/dev/null 2>&1 && - ( yes "" | git mergetool file1 >/dev/null 2>&1 ) && - ( yes "" | git mergetool file2 >/dev/null 2>&1 ) && - ( yes "" | git mergetool "spaced name" >/dev/null 2>&1 ) && - ( yes "" | git mergetool both >/dev/null 2>&1 ) && - ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) && - ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) && - ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) && - ( yes "r" | git mergetool submod >/dev/null 2>&1 ) && + test_must_fail git merge master && + ( yes "" | git mergetool file1 ) && + ( yes "" | git mergetool file2 ) && + ( yes "" | git mergetool "spaced name" ) && + ( yes "" | git mergetool both ) && + ( yes "" | git mergetool subdir/file3 ) && + ( yes "d" | git mergetool file11 ) && + ( yes "d" | git mergetool file12 ) && + ( yes "r" | git mergetool submod ) && test "$(printf x | cat file1 -)" = "$(printf "master updated\r\nx")" && test "$(printf x | cat file2 -)" = "$(printf "master new\r\nx")" && test "$(printf x | cat subdir/file3 -)" = "$(printf "master new sub\r\nx")" && @@ -176,8 +176,8 @@ test_expect_success 'mergetool in subdir' ' git submodule update -N && ( cd subdir && - test_must_fail git merge master >/dev/null 2>&1 && - ( yes "" | git mergetool file3 >/dev/null 2>&1 ) && + test_must_fail git merge master && + ( yes "" | git mergetool file3 ) && test "$(cat file3)" = "master new sub" ) ' @@ -188,14 +188,14 @@ test_expect_success 'mergetool on file in parent dir' ' git submodule update -N && ( cd subdir && - test_must_fail git merge master >/dev/null 2>&1 && - ( yes "" | git mergetool file3 >/dev/null 2>&1 ) && - ( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) && - ( yes "" | git mergetool ../file2 ../spaced\ name >/dev/null 2>&1 ) && - ( yes "" | git mergetool ../both >/dev/null 2>&1 ) && - ( yes "d" | git mergetool ../file11 >/dev/null 2>&1 ) && - ( yes "d" | git mergetool ../file12 >/dev/null 2>&1 ) && - ( yes "l" | git mergetool ../submod >/dev/null 2>&1 ) && + test_must_fail git merge master && + ( yes "" | git mergetool file3 ) && + ( yes "" | git mergetool ../file1 ) && + ( yes "" | git mergetool ../file2 ../spaced\ name ) && + ( yes "" | git mergetool ../both ) && + ( yes "d" | git mergetool ../file11 ) && + ( yes "d" | git mergetool ../file12 ) && + ( yes "l" | git mergetool ../submod ) && test "$(cat ../file1)" = "master updated" && test "$(cat ../file2)" = "master new" && test "$(cat ../submod/bar)" = "branch1 submodule" && @@ -209,9 +209,9 @@ test_expect_success 'mergetool skips autoresolved' ' git submodule update -N && test_must_fail git merge master && test -n "$(git ls-files -u)" && - ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) && - ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) && - ( yes "l" | git mergetool submod >/dev/null 2>&1 ) && + ( yes "d" | git mergetool file11 ) && + ( yes "d" | git mergetool file12 ) && + ( yes "l" | git mergetool submod ) && output="$(git mergetool --no-prompt)" && test "$output" = "No files need merging" ' @@ -259,9 +259,9 @@ test_expect_success 'mergetool skips resolved paths when rerere is active' ' rm -rf .git/rr-cache && git checkout -b test$test_count branch1 && git submodule update -N && - test_must_fail git merge master >/dev/null 2>&1 && - ( yes "l" | git mergetool --no-prompt submod >/dev/null 2>&1 ) && - ( yes "d" "d" | git mergetool --no-prompt >/dev/null 2>&1 ) && + test_must_fail git merge master && + ( yes "l" | git mergetool --no-prompt submod ) && + ( yes "d" "d" | git mergetool --no-prompt ) && git submodule update -N && output="$(yes "n" | git mergetool --no-prompt)" && test "$output" = "No files need merging" @@ -369,9 +369,9 @@ test_expect_success 'deleted vs modified submodule' ' git checkout -b test$test_count.a test$test_count && test_must_fail git merge master && test -n "$(git ls-files -u)" && - ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && - ( yes "" | git mergetool both >/dev/null 2>&1 ) && - ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && + ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 ) && + ( yes "" | git mergetool both ) && + ( yes "d" | git mergetool file11 file12 ) && ( yes "r" | git mergetool submod ) && rmdir submod && mv submod-movedaside submod && test "$(cat submod/bar)" = "branch1 submodule" && @@ -386,9 +386,9 @@ test_expect_success 'deleted vs modified submodule' ' git submodule update -N && test_must_fail git merge master && test -n "$(git ls-files -u)" && - ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && - ( yes "" | git mergetool both >/dev/null 2>&1 ) && - ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && + ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 ) && + ( yes "" | git mergetool both ) && + ( yes "d" | git mergetool file11 file12 ) && ( yes "l" | git mergetool submod ) && test ! -e submod && output="$(git mergetool --no-prompt)" && @@ -400,9 +400,9 @@ test_expect_success 'deleted vs modified submodule' ' git submodule update -N && test_must_fail git merge test$test_count && test -n "$(git ls-files -u)" && - ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && - ( yes "" | git mergetool both >/dev/null 2>&1 ) && - ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && + ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 ) && + ( yes "" | git mergetool both ) && + ( yes "d" | git mergetool file11 file12 ) && ( yes "r" | git mergetool submod ) && test ! -e submod && test -d submod.orig && @@ -416,9 +416,9 @@ test_expect_success 'deleted vs modified submodule' ' git submodule update -N && test_must_fail git merge test$test_count && test -n "$(git ls-files -u)" && - ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && - ( yes "" | git mergetool both >/dev/null 2>&1 ) && - ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && + ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 ) && + ( yes "" | git mergetool both ) && + ( yes "d" | git mergetool file11 file12 ) && ( yes "l" | git mergetool submod ) && test "$(cat submod/bar)" = "master submodule" && git submodule update -N && @@ -440,9 +440,9 @@ test_expect_success 'file vs modified submodule' ' git checkout -b test$test_count.a branch1 && test_must_fail git merge master && test -n "$(git ls-files -u)" && - ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && - ( yes "" | git mergetool both >/dev/null 2>&1 ) && - ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && + ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 ) && + ( yes "" | git mergetool both ) && + ( yes "d" | git mergetool file11 file12 ) && ( yes "r" | git mergetool submod ) && rmdir submod && mv submod-movedaside submod && test "$(cat submod/bar)" = "branch1 submodule" && @@ -456,9 +456,9 @@ test_expect_success 'file vs modified submodule' ' git checkout -b test$test_count.b test$test_count && test_must_fail git merge master && test -n "$(git ls-files -u)" && - ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && - ( yes "" | git mergetool both >/dev/null 2>&1 ) && - ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && + ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 ) && + ( yes "" | git mergetool both ) && + ( yes "d" | git mergetool file11 file12 ) && ( yes "l" | git mergetool submod ) && git submodule update -N && test "$(cat submod)" = "not a submodule" && @@ -472,9 +472,9 @@ test_expect_success 'file vs modified submodule' ' git submodule update -N && test_must_fail git merge test$test_count && test -n "$(git ls-files -u)" && - ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && - ( yes "" | git mergetool both >/dev/null 2>&1 ) && - ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && + ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 ) && + ( yes "" | git mergetool both ) && + ( yes "d" | git mergetool file11 file12 ) && ( yes "r" | git mergetool submod ) && test -d submod.orig && git submodule update -N && @@ -488,9 +488,9 @@ test_expect_success 'file vs modified submodule' ' git submodule update -N && test_must_fail git merge test$test_count && test -n "$(git ls-files -u)" && - ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && - ( yes "" | git mergetool both>/dev/null 2>&1 ) && - ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && + ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 ) && + ( yes "" | git mergetool both ) && + ( yes "d" | git mergetool file11 file12 ) && ( yes "l" | git mergetool submod ) && test "$(cat submod/bar)" = "master submodule" && git submodule update -N && @@ -543,7 +543,7 @@ test_expect_success 'submodule in subdirectory' ' git add subdir/subdir_module && git commit -m "change submodule in subdirectory on test$test_count.b" && - test_must_fail git merge test$test_count.a >/dev/null 2>&1 && + test_must_fail git merge test$test_count.a && ( cd subdir && ( yes "l" | git mergetool subdir_module ) @@ -554,7 +554,7 @@ test_expect_success 'submodule in subdirectory' ' git reset --hard && git submodule update -N && - test_must_fail git merge test$test_count.a >/dev/null 2>&1 && + test_must_fail git merge test$test_count.a && ( yes "r" | git mergetool subdir/subdir_module ) && test "$(cat subdir/subdir_module/file15)" = "test$test_count.b" && git submodule update -N && @@ -641,7 +641,7 @@ test_expect_success 'filenames seen by tools start with ./' ' test_config mergetool.myecho.trustExitCode true && test_must_fail git merge master && git mergetool --no-prompt --tool myecho -- both >actual && - grep ^\./both_LOCAL_ actual >/dev/null + grep ^\./both_LOCAL_ actual ' test_lazy_prereq MKTEMP ' @@ -658,8 +658,8 @@ test_expect_success MKTEMP 'temporary filenames are used with mergetool.writeToT test_config mergetool.myecho.trustExitCode true && test_must_fail git merge master && git mergetool --no-prompt --tool myecho -- both >actual && - ! grep ^\./both_LOCAL_ actual >/dev/null && - grep /both_LOCAL_ actual >/dev/null + ! grep ^\./both_LOCAL_ actual && + grep /both_LOCAL_ actual ' test_expect_success 'diff.orderFile configuration is honored' ' From patchwork Thu Apr 25 09:54:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10916521 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 00E2713B5 for ; Thu, 25 Apr 2019 09:54:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E500E28BA3 for ; Thu, 25 Apr 2019 09:54:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D8D8128C21; Thu, 25 Apr 2019 09:54:41 +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 80B4D28BA3 for ; Thu, 25 Apr 2019 09:54:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728598AbfDYJyk (ORCPT ); Thu, 25 Apr 2019 05:54:40 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:33098 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728285AbfDYJyj (ORCPT ); Thu, 25 Apr 2019 05:54:39 -0400 Received: by mail-pl1-f196.google.com with SMTP id t16so10855270plo.0 for ; Thu, 25 Apr 2019 02:54:39 -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=cd608Ig3G+RmuqNxHKJ5+L67jKPXtl5IZitUAWtwr60=; b=Wxg4poWM2JVqM2fw3jMAxFfk/PtCZuWVg0vPSzMA1qe9WBY4pVb+fvzeKiCTildNjy mcdn1scWbKel4RDebhn8pMD1hnUw9Ny6rmXJnzXeRVUZCgjJuRN++marAfE753Bj2Upo kC0RgucjB/5Rst33n6h12knGaZKDU+vSms8cX0y0rjjjqwo4hnLSIlrUhEEuvFqR5H+O 6IEgougfOQ8+N+adfHy/+fUDlLGSgbUH9RqK9Whi92cyz1kTdA6Rh4dyFQVgELdddBDR wOCEkxF24EY4G/0m5mHPQB71c0GfRwAo0Ihe8GjkblZdRoUvuT4zjj3/jDS5gltsk54z qOSQ== 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=cd608Ig3G+RmuqNxHKJ5+L67jKPXtl5IZitUAWtwr60=; b=YUQ2Ng6ukD9VwmQXCbqsjUhjmzhDHZGwvwGHg1CvY92wNXy1X6FZnBTSN+DCwD31lQ ZHKLHPKl0ttpGUQutOfwhlrXIZraHM/CL0vmELKKAjl1hfMICq7jDV2VF/rj2/X5VDQA 3zHm+Z00GNgSCqlYJzcqHAdnyqAKHe0ECs1TM6asJzU+kXcpXdHdh8XpaRn4yfQXvLQI HyHIdzhoOVwXjc6+xqzC5tm0xNtAMq7SAORaV76/hCtc69bY9TgdYKTTY4OJpK+2AR/L XKdzc/6TE+v9WMyduFkMJttZReioF8GO2eBsS4YKt8VAOZNiYZPkG3Da322GBtXGa3dt fYxA== X-Gm-Message-State: APjAAAXaTntejjyUZY3uhHX4zIxa5KgQ597wHluPqwVLTwqHMIBAKBeF sCE4YHTD2o/Ss5suninAGEqezqSn X-Google-Smtp-Source: APXvYqxStzWgB9dsJqSoHVzSaW+WltU4TBRtNtTHVUIOvKR27neLWgEb2A8cUpLm88xxQWASyvLpPQ== X-Received: by 2002:a17:902:9884:: with SMTP id s4mr39386427plp.179.1556186078842; Thu, 25 Apr 2019 02:54:38 -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 k65sm45345408pfb.68.2019.04.25.02.54.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Apr 2019 02:54:38 -0700 (PDT) Date: Thu, 25 Apr 2019 02:54:36 -0700 From: Denton Liu To: Git Mailing List Cc: Johannes Schindelin , David Aguilar , Jeff Hostetler , Eric Sunshine , Junio C Hamano Subject: [PATCH v4 2/6] t7610: add mergetool --gui tests Message-ID: <0f632ca6bf4f5e76d18b17435a8e565b4cdc3cc0.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 063f2bdbf7 (mergetool: accept -g/--[no-]gui as arguments, 2018-10-24), mergetool was taught the --gui option but no tests were added to ensure that it was working properly. Add a test to ensure that it works. Signed-off-by: Denton Liu --- t/t7610-mergetool.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh index 69711487dd..dad607e186 100755 --- a/t/t7610-mergetool.sh +++ b/t/t7610-mergetool.sh @@ -145,6 +145,28 @@ test_expect_success 'custom mergetool' ' git commit -m "branch1 resolved with mergetool" ' +test_expect_success 'gui mergetool' ' + test_config merge.guitool myguitool && + test_config mergetool.myguitool.cmd "(printf \"gui \" && cat \"\$REMOTE\") >\"\$MERGED\"" && + test_config mergetool.myguitool.trustExitCode true && + test_when_finished "git reset --hard" && + git checkout -b test$test_count branch1 && + git submodule update -N && + test_must_fail git merge master && + ( yes "" | git mergetool --gui both ) && + ( yes "" | git mergetool -g file1 file1 ) && + ( yes "" | git mergetool --gui file2 "spaced name" ) && + ( yes "" | git mergetool --gui subdir/file3 ) && + ( yes "d" | git mergetool --gui file11 ) && + ( yes "d" | git mergetool --gui file12 ) && + ( yes "l" | git mergetool --gui submod ) && + test "$(cat file1)" = "gui master updated" && + test "$(cat file2)" = "gui master new" && + test "$(cat subdir/file3)" = "gui master new sub" && + test "$(cat submod/bar)" = "branch1 submodule" && + git commit -m "branch1 resolved with mergetool" +' + test_expect_success 'mergetool crlf' ' test_when_finished "git reset --hard" && # This test_config line must go after the above reset line so that From patchwork Thu Apr 25 09:54:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10916523 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 71333161F for ; Thu, 25 Apr 2019 09:54:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F38728BA3 for ; Thu, 25 Apr 2019 09:54:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 532B328C21; Thu, 25 Apr 2019 09:54:45 +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 D5D8B28BA3 for ; Thu, 25 Apr 2019 09:54:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728599AbfDYJyn (ORCPT ); Thu, 25 Apr 2019 05:54:43 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:38927 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727536AbfDYJyn (ORCPT ); Thu, 25 Apr 2019 05:54:43 -0400 Received: by mail-pl1-f195.google.com with SMTP id e92so9046066plb.6 for ; Thu, 25 Apr 2019 02:54:42 -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=YcPgXoo63y989Xy1wxkwt9NSUu0nrafrafCtZon7K5w=; b=bz/uUuo7TAcKPaQOTnXgtngMXU36y2EkvO8Aepq8wqTL9xJq93Aa+YTME+nmAHnml6 fhYTBXUoQzRzxUbE/LaSKTUPO/auPl3RVO1WYeq0LX7YLM0wD5OWcCaW4QEzz6AIPwJB S9Ag3CIEMu6CyO2deVydzCn2BnNv9plTCiXNoH7gk24G3cXVt33FfQK+7ZCeO3HcGBjj JKbus+OUlV4Lm0nR8N3wmRsNmtV76XNGob1KhkDquV5ajDAdr3wgub4++mpoemy+O6S3 XUCoEaP6lFBdRWIfh6H63rUrLlULAyRfoPipCpSh2L7bRoq/4cp8djMl6C7XMuqSacR7 f7IQ== 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=YcPgXoo63y989Xy1wxkwt9NSUu0nrafrafCtZon7K5w=; b=WbQZNbAUTlD4d3hcL2dsIZplQenIA1ceFjeOdwMp1G2WErefH61Jo+CAT+cH4QBrMk 3EEuHVpic1E5GaNE9HRBCCIRoH3x/GNGiIPSrkivID16sej4+YvtlKwqbBRV/lTsC0a9 zuTYbE7h+1RivWH8Io0zCEbf4IQK5Ka5s455e+ovZZ26KV92TjerJfh8z5m60N89qEN5 uk4Cq1pEB6F7fNA0WdCIaFyfisng73rAlhYbryybG0YaMzyDJJawifGYk+2R9yeXDN2V 0aEEPc9XBgXLedI+iAWjeVK0WlB0pUOnlwAZdiiUswjpPnee4Uach91UP00ZvJorEElh SNVw== X-Gm-Message-State: APjAAAUFOLtAfDY6T5UJfeUox+15YWqFlqopDv8Zpc6zpRqy0GFLgaaj ssFzrZB+EjmkFL2UIrx1h/fc0DWx X-Google-Smtp-Source: APXvYqwSnM0dYbV4F3if1xheIEC8Xxzl6WKyjaJ1xO8zxEUtJjWdF5DKweDb+EcMsqsb7jXPKCrchA== X-Received: by 2002:a17:902:b602:: with SMTP id b2mr38428539pls.293.1556186081630; Thu, 25 Apr 2019 02:54:41 -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 o66sm15168688pfb.184.2019.04.25.02.54.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Apr 2019 02:54:40 -0700 (PDT) Date: Thu, 25 Apr 2019 02:54:39 -0700 From: Denton Liu To: Git Mailing List Cc: Johannes Schindelin , David Aguilar , Jeff Hostetler , Eric Sunshine , Junio C Hamano Subject: [PATCH v4 3/6] mergetool: use get_merge_tool function Message-ID: 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-mergetool, the logic for getting which merge tool to use is duplicated in git-mergetool--lib, except for the fact that it needs to know whether the tool was guessed or not. Rewrite `get_merge_tool` to return whether or not the tool was guessed through the return code and make git-mergetool call this function instead of duplicating the logic. Note that 1 was chosen to be the return code of when a tool is guessed because it seems like a slightly more abnormal condition than getting a tool that's explicitly specified but this is completely arbitrary. Also, let `$GIT_MERGETOOL_GUI` be set to determine whether or not the guitool will be selected. This change is not completely backwards compatible as there may be external users of git-mergetool--lib. However, only one user, git-diffall[1], was found from searching GitHub and Google. It seems very unlikely that there exists an external caller that would take into account the return code of `get_merge_tool` as it would always return 0 before this change so this change probably does not affect any external users. [1]: https://github.com/thenigan/git-diffall Signed-off-by: Denton Liu --- Documentation/git-mergetool--lib.txt | 4 +++- git-difftool--helper.sh | 2 +- git-mergetool--lib.sh | 5 ++++- git-mergetool.sh | 12 ++++-------- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Documentation/git-mergetool--lib.txt b/Documentation/git-mergetool--lib.txt index 055550b2bc..4da9d24096 100644 --- a/Documentation/git-mergetool--lib.txt +++ b/Documentation/git-mergetool--lib.txt @@ -28,7 +28,9 @@ to define the operation mode for the functions listed below. FUNCTIONS --------- get_merge_tool:: - returns a merge tool. + returns a merge tool. the return code is 1 if we returned a guessed + merge tool, else 0. '$GIT_MERGETOOL_GUI' may be set to 'true' to + search for the appropriate guitool. get_merge_tool_cmd:: returns the custom command for a merge tool. diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh index 7bfb6737df..46af3e60b7 100755 --- a/git-difftool--helper.sh +++ b/git-difftool--helper.sh @@ -71,7 +71,7 @@ then then merge_tool="$GIT_DIFF_TOOL" else - merge_tool="$(get_merge_tool)" || exit + merge_tool="$(get_merge_tool)" fi fi diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh index 83bf52494c..68ff26a0f7 100644 --- a/git-mergetool--lib.sh +++ b/git-mergetool--lib.sh @@ -403,14 +403,17 @@ get_merge_tool_path () { } get_merge_tool () { + not_guessed=true # Check if a merge tool has been configured - merge_tool=$(get_configured_merge_tool) + merge_tool=$(get_configured_merge_tool $GIT_MERGETOOL_GUI) # Try to guess an appropriate merge tool if no tool has been set. if test -z "$merge_tool" then merge_tool=$(guess_merge_tool) || exit + not_guessed=false fi echo "$merge_tool" + test "$not_guessed" = true } mergetool_find_win32_cmd () { diff --git a/git-mergetool.sh b/git-mergetool.sh index 01b9ad59b2..88fa6a914a 100755 --- a/git-mergetool.sh +++ b/git-mergetool.sh @@ -389,7 +389,7 @@ print_noop_and_exit () { main () { prompt=$(git config --bool mergetool.prompt) - gui_tool=false + GIT_MERGETOOL_GUI=false guessed_merge_tool=false orderfile= @@ -416,10 +416,10 @@ main () { esac ;; --no-gui) - gui_tool=false + GIT_MERGETOOL_GUI=false ;; -g|--gui) - gui_tool=true + GIT_MERGETOOL_GUI=true ;; -y|--no-prompt) prompt=false @@ -449,12 +449,8 @@ main () { if test -z "$merge_tool" then - # Check if a merge tool has been configured - 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" + if ! merge_tool=$(get_merge_tool) then - merge_tool=$(guess_merge_tool) || exit guessed_merge_tool=true fi fi From patchwork Thu Apr 25 09:54:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10916525 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 59BB5161F for ; Thu, 25 Apr 2019 09:54:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4846D28BA3 for ; Thu, 25 Apr 2019 09:54:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C71028C21; Thu, 25 Apr 2019 09:54: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 BCDAD28BA3 for ; Thu, 25 Apr 2019 09:54:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728639AbfDYJyr (ORCPT ); Thu, 25 Apr 2019 05:54:47 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:34899 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727536AbfDYJyp (ORCPT ); Thu, 25 Apr 2019 05:54:45 -0400 Received: by mail-pg1-f193.google.com with SMTP id h1so668574pgs.2 for ; Thu, 25 Apr 2019 02:54:45 -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=jSGjDqg6H4RXodxcuBunJGLalRidYZTF6HY4l5Ijv+w=; b=nzuBHy0heX1oxzl4B2/9iQPNC3QIL3smvbeZ+kkzFZ2469GxiTWdjHPRs/Aywycg/9 DFEUVJHf51FZaW44qS7+pJ47DBICokvOyfkZMK3nn+gNuuJMuyBgOwXF4Aok2OO/PAl/ RyWNJnXG3kMczGUR4dT5e87s2LDgNjXdocqIadgpko7LhKab77JGU1AhMsEoEmXV27NK hcWSn4fFjL6bg84JkG2NhdCqBr/E6H9aZhWB8KWVKuHNZSgB+LpwPGPSANKsBfugMeno J4vXyp5JeDavqoUBsro/ED/V9RxrUIgDfylisgjPx4k7cKJvFbyHOPCw56xZWdlfMZdA wmcg== 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=jSGjDqg6H4RXodxcuBunJGLalRidYZTF6HY4l5Ijv+w=; b=dhz0X9C/38vpCAuLJqxTYJTPYHYknyJ+p514bPH3MDPXP6PjqzXcZUWHRyA5c3g+lB PDxq4UjJkvbFMbgaDnXuAnn9C2KAHgUKlLjY969wlTtX46zMDhbMZrRD6fBvPlAGN6ra wOcGyRCLKRL0mlj7fjQRTfYVe0Pia4LLXpyv3KEOR+tXSzVETnyy3R1i3+oKfbLoTetk tv2+KIaV9sPQLw4PYk2SZ9Aq61/AT+5u5xmNSW1fKIEwfchhBaWIc/hhVYI+4KcCR8HF JW5kpB4c4KeZsEy/69/iUhJv8vGuAHHw7TIO9moM6lrR77R6c9SopNjME5Vo8wJvMWGZ tICg== X-Gm-Message-State: APjAAAWgRYs9zcZeGV+OAUHgnCLm2Wjhw9VOMP0RCiYfejZQmwgUIdXC VzLqxkQdrs5nqPxmTvi3H9yb/e65 X-Google-Smtp-Source: APXvYqwpCy6IUtjas2BI+jAGKXCtyj9UAAyxoyTjUTjM7hpWanHcMiZZidvX1TwJ5hbKVFRnnS2rZw== X-Received: by 2002:a65:6205:: with SMTP id d5mr736648pgv.61.1556186084402; Thu, 25 Apr 2019 02:54:44 -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 j16sm29690813pfi.58.2019.04.25.02.54.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Apr 2019 02:54:43 -0700 (PDT) Date: Thu, 25 Apr 2019 02:54:41 -0700 From: Denton Liu To: Git Mailing List Cc: Johannes Schindelin , David Aguilar , Jeff Hostetler , Eric Sunshine , Junio C Hamano Subject: [PATCH v4 4/6] mergetool: fallback to tool when guitool unavailable Message-ID: 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, if the tool is called with --gui but `diff.guitool` is not set, it falls back to `diff.tool`. Make git-mergetool also fallback from `merge.guitool` to `merge.tool` if the former is undefined. If git-difftool, when called with `--gui`, were to use `get_configured_mergetool` in a future patch, it would also get the fallback behavior in the following precedence: 1. diff.guitool 2. merge.guitool 3. diff.tool 4. merge.tool Note that the behavior for when difftool or mergetool are called without `--gui` should be identical with or without this patch. Signed-off-by: Denton Liu --- Documentation/git-mergetool.txt | 4 +++- git-mergetool--lib.sh | 32 +++++++++++++++++++++++--------- t/t7610-mergetool.sh | 19 +++++++++++++++++++ 3 files changed, 45 insertions(+), 10 deletions(-) diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt index 0c7975a050..6b14702e78 100644 --- a/Documentation/git-mergetool.txt +++ b/Documentation/git-mergetool.txt @@ -83,7 +83,9 @@ success of the resolution after the custom tool has exited. --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`. + `merge.guitool` variable instead of `merge.tool`. If + `merge.guitool` is not set, we will fallback to the tool + configured under `merge.tool`. --no-gui:: This overrides a previous `-g` or `--gui` setting and reads the diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh index 68ff26a0f7..c4b16c5e59 100644 --- a/git-mergetool--lib.sh +++ b/git-mergetool--lib.sh @@ -350,20 +350,34 @@ guess_merge_tool () { } get_configured_merge_tool () { - # If first argument is true, find the guitool instead - if test "$1" = true + is_gui="$1" + sections="merge" + keys="tool" + + if diff_mode then - gui_prefix=gui + sections="diff $sections" 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 + if "$is_gui" = true then - merge_tool=$(git config diff.${gui_prefix}tool || git config merge.${gui_prefix}tool) - else - merge_tool=$(git config merge.${gui_prefix}tool) + keys="guitool $keys" fi + + merge_tool=$( + IFS=' ' + for key in $keys + do + for section in $sections + do + if selected=$(git config $section.$key) + then + echo "$selected" + return + fi + done + done) + if test -n "$merge_tool" && ! valid_tool "$merge_tool" then echo >&2 "git config option $TOOL_MODE.${gui_prefix}tool set to unknown tool: $merge_tool" diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh index dad607e186..5b61c10a9c 100755 --- a/t/t7610-mergetool.sh +++ b/t/t7610-mergetool.sh @@ -167,6 +167,25 @@ test_expect_success 'gui mergetool' ' git commit -m "branch1 resolved with mergetool" ' +test_expect_success 'gui mergetool without merge.guitool set falls back to merge.tool' ' + test_when_finished "git reset --hard" && + git checkout -b test$test_count branch1 && + git submodule update -N && + test_must_fail git merge master && + ( yes "" | git mergetool --gui both ) && + ( yes "" | git mergetool -g file1 file1 ) && + ( yes "" | git mergetool --gui file2 "spaced name" ) && + ( yes "" | git mergetool --gui subdir/file3 ) && + ( yes "d" | git mergetool --gui file11 ) && + ( yes "d" | git mergetool --gui file12 ) && + ( yes "l" | git mergetool --gui submod ) && + test "$(cat file1)" = "master updated" && + test "$(cat file2)" = "master new" && + test "$(cat subdir/file3)" = "master new sub" && + test "$(cat submod/bar)" = "branch1 submodule" && + git commit -m "branch1 resolved with mergetool" +' + test_expect_success 'mergetool crlf' ' test_when_finished "git reset --hard" && # This test_config line must go after the above reset line so that 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 From patchwork Thu Apr 25 09:54:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10916529 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 F156E161F for ; Thu, 25 Apr 2019 09:54:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE6B92899D for ; Thu, 25 Apr 2019 09:54:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CFDA228BA3; Thu, 25 Apr 2019 09:54:53 +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 5FFD62899D for ; Thu, 25 Apr 2019 09:54:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728713AbfDYJyw (ORCPT ); Thu, 25 Apr 2019 05:54:52 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:38937 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727536AbfDYJyu (ORCPT ); Thu, 25 Apr 2019 05:54:50 -0400 Received: by mail-pl1-f193.google.com with SMTP id e92so9046273plb.6 for ; Thu, 25 Apr 2019 02:54:50 -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=YZgysgXEhpqkUO8cf301jh4x0JoX/GnOM6QKUIXwyDo=; b=G2J45R+L6Rd1oqageZX1iuj9/aGwFonbDwOYoTEX3aMvFe8Tk/0JuYWZx7JBqZ3Fge vAzaYE3gly+asbo89+eGmltAkjj/VXoSDRfuKvtsHvn5nGuM+JxZh31NYCcf73XlAVh/ ioXhRQ3T4rBS36dCEDICAvGwq2sUzmHKsq4JA6p/KvYxfnghcqINsVv5LPIwEyycb37/ MOShzMlBafQ5NJXLjjYk99trg90t4QpYjqkREYF+G7BnV+dZsEKWQjbYh+AT4KCuq/QT 8BKftQBXy8DNmNbY/XTRqofaAnIo2PQR70is0Frj8MJev5KR7njslyxNbk+nA8LVF5kW xrOA== 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=YZgysgXEhpqkUO8cf301jh4x0JoX/GnOM6QKUIXwyDo=; b=LBAcsnOwRhUWvBlmWZ6xVWZGHggLZcMTtk3vxbSMEXcuhgcCKc9HbxsAAIs6DVAOuX X7BiVM4Jc3UFcoZAFuNsTf2NN0h4Dq3+ExaROB5elyKdM90pujwbod64HUCAsOMf3z4I fvJ5mHVnM9fJBfL4sLc9MzZX+C/P43OL1d8argIuDe9Hoz8kGJEFWfXIdBXiL0k5JSp2 3ddV0gJkHWPDkKYuWVZAjhmliirn7yP0AnLpixOJXrK4g4BMuwI0GZxZx32CXs2Pix0g 0DGNvNGMizC/+mPKG5l2K8eF1FeKJW8Jiy0M33hEH7E5hj0RDPxFpBFk1CXzQrwWqsen TweQ== X-Gm-Message-State: APjAAAXKRKZGPaZZ+q4KWschgAQFkkjUazNfoD67d1hcQYcDSYx5WgKe OMoQWUPu/1kv1AluCooTMZ4aTFXK X-Google-Smtp-Source: APXvYqyR6LeKpuotgvn708qTORy9csM4J5i4cQW/rvM3GwN+0fTZEcNnbET9fpyYacTXTqPekkHsDw== X-Received: by 2002:a17:902:be18:: with SMTP id r24mr36883216pls.69.1556186089873; Thu, 25 Apr 2019 02:54:49 -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 k186sm38932865pfc.137.2019.04.25.02.54.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Apr 2019 02:54:49 -0700 (PDT) Date: Thu, 25 Apr 2019 02:54:47 -0700 From: Denton Liu To: Git Mailing List Cc: Johannes Schindelin , David Aguilar , Jeff Hostetler , Eric Sunshine , Junio C Hamano Subject: [PATCH v4 6/6] difftool: fallback on merge.guitool Message-ID: 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.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 '