update-ref --stdin: make error messages more consistent

The old error messages emitted for invalid input sometimes said "<oldvalue>"/"<newvalue>" and sometimes said "old value"/"new value". Convert them all to the former. Update the tests accordingly. 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:48 UTC 9255f059ff0bfce7605748f62f58d6ba9055a1f3
2 files changed +11 -11
builtin/update-ref.c
+4 -4
@@ -40,7 +40,7 @@ static void update_store_new_sha1(const char *command,
40 const char *newvalue)
41 {
42 if (*newvalue && get_sha1(newvalue, update->new_sha1))
43 - die("%s %s: invalid new value: %s",
43 + die("%s %s: invalid <newvalue>: %s",
44 command, update->ref_name, newvalue);
45 }
46
@@ -49,7 +49,7 @@ static void update_store_old_sha1(const char *command,
49 const char *oldvalue)
50 {
51 if (*oldvalue && get_sha1(oldvalue, update->old_sha1))
52 - die("%s %s: invalid old value: %s",
52 + die("%s %s: invalid <oldvalue>: %s",
53 command, update->ref_name, oldvalue);
54
55 /* We have an old value if non-empty, or if empty without -z */
@@ -198,7 +198,7 @@ static const char *parse_cmd_create(struct strbuf *input, const char *next)
198 die("create %s missing <newvalue>", update->ref_name);
199
200 if (is_null_sha1(update->new_sha1))
201 - die("create %s given zero new value", update->ref_name);
201 + die("create %s given zero <newvalue>", update->ref_name);
202
203 if (*next != line_termination)
204 die("create %s has extra input: %s", update->ref_name, next);
@@ -220,7 +220,7 @@ static const char *parse_cmd_delete(struct strbuf *input, const char *next)
220 if (!parse_next_arg(input, &next, &oldvalue)) {
221 update_store_old_sha1("delete", update, oldvalue.buf);
222 if (update->have_old && is_null_sha1(update->old_sha1))
223 - die("delete %s given zero old value", update->ref_name);
223 + die("delete %s given zero <oldvalue>", update->ref_name);
224 } else if (!line_termination)
225 die("delete %s missing [<oldvalue>] NUL", update->ref_name);
226
t/t1400-update-ref.sh
+7 -7
@@ -518,21 +518,21 @@ test_expect_success 'stdin update ref fails with wrong old value' '
518 test_expect_success 'stdin update ref fails with bad old value' '
519 echo "update $c $m does-not-exist" >stdin &&
520 test_must_fail git update-ref --stdin <stdin 2>err &&
521 - grep "fatal: update $c: invalid old value: does-not-exist" err &&
521 + grep "fatal: update $c: invalid <oldvalue>: does-not-exist" err &&
522 test_must_fail git rev-parse --verify -q $c
523 '
524
525 test_expect_success 'stdin create ref fails with bad new value' '
526 echo "create $c does-not-exist" >stdin &&
527 test_must_fail git update-ref --stdin <stdin 2>err &&
528 - grep "fatal: create $c: invalid new value: does-not-exist" err &&
528 + grep "fatal: create $c: invalid <newvalue>: does-not-exist" err &&
529 test_must_fail git rev-parse --verify -q $c
530 '
531
532 test_expect_success 'stdin create ref fails with zero new value' '
533 echo "create $c " >stdin &&
534 test_must_fail git update-ref --stdin <stdin 2>err &&
535 - grep "fatal: create $c given zero new value" err &&
535 + grep "fatal: create $c given zero <newvalue>" err &&
536 test_must_fail git rev-parse --verify -q $c
537 '
538
@@ -556,7 +556,7 @@ test_expect_success 'stdin delete ref fails with wrong old value' '
556 test_expect_success 'stdin delete ref fails with zero old value' '
557 echo "delete $a " >stdin &&
558 test_must_fail git update-ref --stdin <stdin 2>err &&
559 - grep "fatal: delete $a given zero old value" err &&
559 + grep "fatal: delete $a given zero <oldvalue>" err &&
560 git rev-parse $m >expect &&
561 git rev-parse $a >actual &&
562 test_cmp expect actual
@@ -840,14 +840,14 @@ test_expect_success 'stdin -z update ref fails with wrong old value' '
840 test_expect_success 'stdin -z update ref fails with bad old value' '
841 printf $F "update $c" "$m" "does-not-exist" >stdin &&
842 test_must_fail git update-ref -z --stdin <stdin 2>err &&
843 - grep "fatal: update $c: invalid old value: does-not-exist" err &&
843 + grep "fatal: update $c: invalid <oldvalue>: does-not-exist" err &&
844 test_must_fail git rev-parse --verify -q $c
845 '
846
847 test_expect_success 'stdin -z create ref fails with bad new value' '
848 printf $F "create $c" "does-not-exist" >stdin &&
849 test_must_fail git update-ref -z --stdin <stdin 2>err &&
850 - grep "fatal: create $c: invalid new value: does-not-exist" err &&
850 + grep "fatal: create $c: invalid <newvalue>: does-not-exist" err &&
851 test_must_fail git rev-parse --verify -q $c
852 '
853
@@ -878,7 +878,7 @@ test_expect_success 'stdin -z delete ref fails with wrong old value' '
878 test_expect_success 'stdin -z delete ref fails with zero old value' '
879 printf $F "delete $a" "$Z" >stdin &&
880 test_must_fail git update-ref -z --stdin <stdin 2>err &&
881 - grep "fatal: delete $a given zero old value" err &&
881 + grep "fatal: delete $a given zero <oldvalue>" err &&
882 git rev-parse $m >expect &&
883 git rev-parse $a >actual &&
884 test_cmp expect actual