Re: [PATCH 05/26] t1400: Add some more tests involving quoted arguments

2014-03-10 Thread Johan Herland
On Mon, Mar 10, 2014 at 1:46 PM, Michael Haggerty  wrote:
> Previously there were no good tests of C-quoted arguments.
>
> Signed-off-by: Michael Haggerty 

FWIW, the first 5 patches seem trivially correct to me. Feel free to add:

Reviewed-by: Johan Herland 

-- 
Johan Herland, 
www.herland.net
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/26] t1400: Add some more tests involving quoted arguments

2014-03-10 Thread Michael Haggerty
Previously there were no good tests of C-quoted arguments.

Signed-off-by: Michael Haggerty 
---
 t/t1400-update-ref.sh | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
index 5836842..627aaaf 100755
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
@@ -350,12 +350,18 @@ test_expect_success 'stdin fails on unknown command' '
grep "fatal: unknown command: unknown $a" err
 '
 
-test_expect_success 'stdin fails on badly quoted input' '
+test_expect_success 'stdin fails on unbalanced quotes' '
echo "create $a \"master" >stdin &&
test_must_fail git update-ref --stdin err &&
grep "fatal: badly quoted argument: \\\"master" err
 '
 
+test_expect_success 'stdin fails on invalid escape' '
+   echo "create $a \"ma\zter\"" >stdin &&
+   test_must_fail git update-ref --stdin err &&
+   grep "fatal: badly quoted argument: \\\"mazter\\\"" err
+'
+
 test_expect_success 'stdin fails on junk after quoted argument' '
echo "create \"$a\"master" >stdin &&
test_must_fail git update-ref --stdin err &&
@@ -458,6 +464,24 @@ test_expect_success 'stdin create ref works' '
test_cmp expect actual
 '
 
+test_expect_success 'stdin succeeds with quoted argument' '
+   git update-ref -d $a &&
+   echo "create $a \"$m\"" >stdin &&
+   git update-ref --stdin expect &&
+   git rev-parse $a >actual &&
+   test_cmp expect actual
+'
+
+test_expect_success 'stdin succeeds with escaped character' '
+   git update-ref -d $a &&
+   echo "create $a \"ma\\163ter\"" >stdin &&
+   git update-ref --stdin expect &&
+   git rev-parse $a >actual &&
+   test_cmp expect actual
+'
+
 test_expect_success 'stdin update ref creates with zero old value' '
echo "update $b $m $Z" >stdin &&
git update-ref --stdin http://vger.kernel.org/majordomo-info.html