Skip to contentSkip to conversation

mergetool: Suppress stderr and fix the "both added" test

PATCH In review David Aguilar 2 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mergetool: Suppress stderr and fix the "both added" test

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

---
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(-)
git-mergetool.sh +3 -1
index 24bedc5..a9f23f7 100755
@@ -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"
t/t7610-mergetool.sh +3 -2
index 2272743..3f261a3 100755
@@ -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
 '
 
Signature · 1 line
1.7.7.166.g1cd0c
#1 lore raw
Quoted 5 lines · David Aguilar

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.

Quoted 7 lines

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

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

#2 lore raw
Quoted 15 lines · Junio C Hamano
Quoted 5 lines · David Aguilar

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.

Quoted 7 lines

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

---
This applies on top of da/maint-mergetool-twoway in pu.

Quoted 5 lines

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