git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Aguilar <davvid@gmail.com>
To: gitster@pobox.com
Cc: jcwenger@gmail.com, git@vger.kernel.org
Subject: [PATCH] mergetool: Suppress stderr and fix the "both added" test
Date: Sat, 21 Jan 2012 02:26:18 -0800	[thread overview]
Message-ID: <1327141578-54796-1-git-send-email-davvid@gmail.com> (raw)

Silence error messages when "git checkout-index" is used to
checkout a stage that does not exist.  This can happen now that
mergetool calls checkout_staged_file() unconditionally when
creating the temporary $BASE, $LOCAL, and $REMOTE files.

Fix the test so that it checks the contents of the "both added"
file.  The test was passing as a consequence of accidentally
handing a bad path to "cat".

Signed-off-by: David Aguilar <davvid@gmail.com>
---
This applies on top of da/maint-mergetool-twoway in pu.

 git-mergetool.sh     |    4 +++-
 t/t7610-mergetool.sh |    5 +++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/git-mergetool.sh b/git-mergetool.sh
index 24bedc5..a9f23f7 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -181,7 +181,9 @@ stage_submodule () {
 }
 
 checkout_staged_file () {
-    tmpfile=$(expr "$(git checkout-index --temp --stage="$1" "$2")" : '\([^	]*\)	')
+    tmpfile=$(expr \
+	    "$(git checkout-index --temp --stage="$1" "$2" 2>/dev/null)" \
+	    : '\([^	]*\)	')
 
     if test $? -eq 0 -a -n "$tmpfile" ; then
 	mv -- "$(git rev-parse --show-cdup)$tmpfile" "$3"
diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh
index 2272743..3f261a3 100755
--- a/t/t7610-mergetool.sh
+++ b/t/t7610-mergetool.sh
@@ -465,8 +465,9 @@ test_expect_success 'directory vs modified submodule' '
 test_expect_success 'file with no base' '
     git checkout -b test13 branch1 &&
     test_must_fail git merge master &&
-    git mergetool --no-prompt --tool mybase -- base &&
-    test "$(cat "$MERGED")" = "" &&
+    git mergetool --no-prompt --tool mybase -- both &&
+    >expected &&
+    test_cmp both expected &&
     git reset --hard master >/dev/null 2>&1
 '
 
-- 
1.7.7.166.g1cd0c

             reply	other threads:[~2012-01-21 10:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-21 10:26 David Aguilar [this message]
2012-01-21 21:27 ` [PATCH] mergetool: Suppress stderr and fix the "both added" test Junio C Hamano
2012-01-21 23:58   ` David Aguilar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1327141578-54796-1-git-send-email-davvid@gmail.com \
    --to=davvid@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jcwenger@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).