All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mergetool: Suppress stderr and fix the "both added" test
@ 2012-01-21 10:26 David Aguilar
  2012-01-21 21:27 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: David Aguilar @ 2012-01-21 10:26 UTC (permalink / raw)
  To: gitster; +Cc: jcwenger, git

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mergetool: Suppress stderr and fix the "both added" test
  2012-01-21 10:26 [PATCH] mergetool: Suppress stderr and fix the "both added" test David Aguilar
@ 2012-01-21 21:27 ` Junio C Hamano
  2012-01-21 23:58   ` David Aguilar
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2012-01-21 21:27 UTC (permalink / raw)
  To: David Aguilar; +Cc: jcwenger, git

David Aguilar <davvid@gmail.com> writes:

> 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.

Thanks.

It might make sense to squash this into the previous patch, which luckily
hasn't hit 'next' yet, though---which I can do locally without need for
re-send if you like.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mergetool: Suppress stderr and fix the "both added" test
  2012-01-21 21:27 ` Junio C Hamano
@ 2012-01-21 23:58   ` David Aguilar
  0 siblings, 0 replies; 3+ messages in thread
From: David Aguilar @ 2012-01-21 23:58 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: jcwenger, git

On Jan 21, 2012, at 1:27 PM, Junio C Hamano <gitster@pobox.com> wrote:

> David Aguilar <davvid@gmail.com> writes:
>
>> 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.
>
> Thanks.
>
> It might make sense to squash this into the previous patch, which luckily
> hasn't hit 'next' yet, though---which I can do locally without need for
> re-send if you like.

Yes, please squash this commit. This is certainly a fix up.

Thanks,
David

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-01-21 23:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-21 10:26 [PATCH] mergetool: Suppress stderr and fix the "both added" test David Aguilar
2012-01-21 21:27 ` Junio C Hamano
2012-01-21 23:58   ` David Aguilar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.