t1400: add some more tests involving quoted arguments

Previously there were no good tests of C-quoted arguments. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Apr 7, 2014 at 15:47 UTC 20fcffcc8de9fcfba15fce916ff38c98ca20323d
1 file changed +25 -1
t/t1400-update-ref.sh
+25 -1
@@ -350,12 +350,18 @@ test_expect_success 'stdin fails on unknown command' '
350 grep "fatal: unknown command: unknown $a" err
351 '
352
353 -test_expect_success 'stdin fails on badly quoted input' '
353 +test_expect_success 'stdin fails on unbalanced quotes' '
354 echo "create $a \"master" >stdin &&
355 test_must_fail git update-ref --stdin <stdin 2>err &&
356 grep "fatal: badly quoted argument: \\\"master" err
357 '
358
359 +test_expect_success 'stdin fails on invalid escape' '
360 + echo "create $a \"ma\zter\"" >stdin &&
361 + test_must_fail git update-ref --stdin <stdin 2>err &&
362 + grep "fatal: badly quoted argument: \\\"ma\\\\zter\\\"" err
363 +'
364 +
365 test_expect_success 'stdin fails on junk after quoted argument' '
366 echo "create \"$a\"master" >stdin &&
367 test_must_fail git update-ref --stdin <stdin 2>err &&
@@ -458,6 +464,24 @@ test_expect_success 'stdin create ref works' '
464 test_cmp expect actual
465 '
466
467 +test_expect_success 'stdin succeeds with quoted argument' '
468 + git update-ref -d $a &&
469 + echo "create $a \"$m\"" >stdin &&
470 + git update-ref --stdin <stdin &&
471 + git rev-parse $m >expect &&
472 + git rev-parse $a >actual &&
473 + test_cmp expect actual
474 +'
475 +
476 +test_expect_success 'stdin succeeds with escaped character' '
477 + git update-ref -d $a &&
478 + echo "create $a \"ma\\163ter\"" >stdin &&
479 + git update-ref --stdin <stdin &&
480 + git rev-parse $m >expect &&
481 + git rev-parse $a >actual &&
482 + test_cmp expect actual
483 +'
484 +
485 test_expect_success 'stdin update ref creates with zero old value' '
486 echo "update $b $m $Z" >stdin &&
487 git update-ref --stdin <stdin &&