update-ref --stdin: harmonize error messages

Make (most of) the error messages for invalid input have the same format [1]: $COMMAND [SP $REFNAME]: $MESSAGE Update the tests accordingly. [1] A few error messages are left with their old form, because $COMMAND and $REFNAME aren't passed all the way down the call stack. Maybe those sites should be changed some day, too. 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 f11b09fb60556954c6a222f4809631470c81cae6
2 files changed +28 -28
builtin/update-ref.c
+12 -12
@@ -202,19 +202,19 @@ static const char *parse_cmd_update(struct strbuf *input, const char *next)
202
203 update->ref_name = parse_refname(input, &next);
204 if (!update->ref_name)
205 - die("update line missing <ref>");
205 + die("update: missing <ref>");
206
207 if (parse_next_sha1(input, &next, update->new_sha1,
208 "update", update->ref_name,
209 PARSE_SHA1_ALLOW_EMPTY))
210 - die("update %s missing <newvalue>", update->ref_name);
210 + die("update %s: missing <newvalue>", update->ref_name);
211
212 update->have_old = !parse_next_sha1(input, &next, update->old_sha1,
213 "update", update->ref_name,
214 PARSE_SHA1_OLD);
215
216 if (*next != line_termination)
217 - die("update %s has extra input: %s", update->ref_name, next);
217 + die("update %s: extra input: %s", update->ref_name, next);
218
219 return next;
220 }
@@ -227,17 +227,17 @@ static const char *parse_cmd_create(struct strbuf *input, const char *next)
227
228 update->ref_name = parse_refname(input, &next);
229 if (!update->ref_name)
230 - die("create line missing <ref>");
230 + die("create: missing <ref>");
231
232 if (parse_next_sha1(input, &next, update->new_sha1,
233 "create", update->ref_name, 0))
234 - die("create %s missing <newvalue>", update->ref_name);
234 + die("create %s: missing <newvalue>", update->ref_name);
235
236 if (is_null_sha1(update->new_sha1))
237 - die("create %s given zero <newvalue>", update->ref_name);
237 + die("create %s: zero <newvalue>", update->ref_name);
238
239 if (*next != line_termination)
240 - die("create %s has extra input: %s", update->ref_name, next);
240 + die("create %s: extra input: %s", update->ref_name, next);
241
242 return next;
243 }
@@ -250,19 +250,19 @@ static const char *parse_cmd_delete(struct strbuf *input, const char *next)
250
251 update->ref_name = parse_refname(input, &next);
252 if (!update->ref_name)
253 - die("delete line missing <ref>");
253 + die("delete: missing <ref>");
254
255 if (parse_next_sha1(input, &next, update->old_sha1,
256 "delete", update->ref_name, PARSE_SHA1_OLD)) {
257 update->have_old = 0;
258 } else {
259 if (is_null_sha1(update->old_sha1))
260 - die("delete %s given zero <oldvalue>", update->ref_name);
260 + die("delete %s: zero <oldvalue>", update->ref_name);
261 update->have_old = 1;
262 }
263
264 if (*next != line_termination)
265 - die("delete %s has extra input: %s", update->ref_name, next);
265 + die("delete %s: extra input: %s", update->ref_name, next);
266
267 return next;
268 }
@@ -275,7 +275,7 @@ static const char *parse_cmd_verify(struct strbuf *input, const char *next)
275
276 update->ref_name = parse_refname(input, &next);
277 if (!update->ref_name)
278 - die("verify line missing <ref>");
278 + die("verify: missing <ref>");
279
280 if (parse_next_sha1(input, &next, update->old_sha1,
281 "verify", update->ref_name, PARSE_SHA1_OLD)) {
@@ -286,7 +286,7 @@ static const char *parse_cmd_verify(struct strbuf *input, const char *next)
286 }
287
288 if (*next != line_termination)
289 - die("verify %s has extra input: %s", update->ref_name, next);
289 + die("verify %s: extra input: %s", update->ref_name, next);
290
291 return next;
292 }
t/t1400-update-ref.sh
+16 -16
@@ -371,7 +371,7 @@ test_expect_success 'stdin fails on junk after quoted argument' '
371 test_expect_success 'stdin fails create with no ref' '
372 echo "create " >stdin &&
373 test_must_fail git update-ref --stdin <stdin 2>err &&
374 - grep "fatal: create line missing <ref>" err
374 + grep "fatal: create: missing <ref>" err
375 '
376
377 test_expect_success 'stdin fails create with bad ref name' '
@@ -383,19 +383,19 @@ test_expect_success 'stdin fails create with bad ref name' '
383 test_expect_success 'stdin fails create with no new value' '
384 echo "create $a" >stdin &&
385 test_must_fail git update-ref --stdin <stdin 2>err &&
386 - grep "fatal: create $a missing <newvalue>" err
386 + grep "fatal: create $a: missing <newvalue>" err
387 '
388
389 test_expect_success 'stdin fails create with too many arguments' '
390 echo "create $a $m $m" >stdin &&
391 test_must_fail git update-ref --stdin <stdin 2>err &&
392 - grep "fatal: create $a has extra input: $m" err
392 + grep "fatal: create $a: extra input: $m" err
393 '
394
395 test_expect_success 'stdin fails update with no ref' '
396 echo "update " >stdin &&
397 test_must_fail git update-ref --stdin <stdin 2>err &&
398 - grep "fatal: update line missing <ref>" err
398 + grep "fatal: update: missing <ref>" err
399 '
400
401 test_expect_success 'stdin fails update with bad ref name' '
@@ -407,19 +407,19 @@ test_expect_success 'stdin fails update with bad ref name' '
407 test_expect_success 'stdin fails update with no new value' '
408 echo "update $a" >stdin &&
409 test_must_fail git update-ref --stdin <stdin 2>err &&
410 - grep "fatal: update $a missing <newvalue>" err
410 + grep "fatal: update $a: missing <newvalue>" err
411 '
412
413 test_expect_success 'stdin fails update with too many arguments' '
414 echo "update $a $m $m $m" >stdin &&
415 test_must_fail git update-ref --stdin <stdin 2>err &&
416 - grep "fatal: update $a has extra input: $m" err
416 + grep "fatal: update $a: extra input: $m" err
417 '
418
419 test_expect_success 'stdin fails delete with no ref' '
420 echo "delete " >stdin &&
421 test_must_fail git update-ref --stdin <stdin 2>err &&
422 - grep "fatal: delete line missing <ref>" err
422 + grep "fatal: delete: missing <ref>" err
423 '
424
425 test_expect_success 'stdin fails delete with bad ref name' '
@@ -431,13 +431,13 @@ test_expect_success 'stdin fails delete with bad ref name' '
431 test_expect_success 'stdin fails delete with too many arguments' '
432 echo "delete $a $m $m" >stdin &&
433 test_must_fail git update-ref --stdin <stdin 2>err &&
434 - grep "fatal: delete $a has extra input: $m" err
434 + grep "fatal: delete $a: extra input: $m" err
435 '
436
437 test_expect_success 'stdin fails verify with too many arguments' '
438 echo "verify $a $m $m" >stdin &&
439 test_must_fail git update-ref --stdin <stdin 2>err &&
440 - grep "fatal: verify $a has extra input: $m" err
440 + grep "fatal: verify $a: extra input: $m" err
441 '
442
443 test_expect_success 'stdin fails option with unknown name' '
@@ -532,7 +532,7 @@ test_expect_success 'stdin create ref fails with bad new value' '
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 <newvalue>" err &&
535 + grep "fatal: create $c: 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 <oldvalue>" err &&
559 + grep "fatal: delete $a: zero <oldvalue>" err &&
560 git rev-parse $m >expect &&
561 git rev-parse $a >actual &&
562 test_cmp expect actual
@@ -697,7 +697,7 @@ test_expect_success 'stdin -z fails on unknown command' '
697 test_expect_success 'stdin -z fails create with no ref' '
698 printf $F "create " >stdin &&
699 test_must_fail git update-ref -z --stdin <stdin 2>err &&
700 - grep "fatal: create line missing <ref>" err
700 + grep "fatal: create: missing <ref>" err
701 '
702
703 test_expect_success 'stdin -z fails create with bad ref name' '
@@ -721,7 +721,7 @@ test_expect_success 'stdin -z fails create with too many arguments' '
721 test_expect_success 'stdin -z fails update with no ref' '
722 printf $F "update " >stdin &&
723 test_must_fail git update-ref -z --stdin <stdin 2>err &&
724 - grep "fatal: update line missing <ref>" err
724 + grep "fatal: update: missing <ref>" err
725 '
726
727 test_expect_success 'stdin -z fails update with too few args' '
@@ -765,7 +765,7 @@ test_expect_success 'stdin -z fails update with too many arguments' '
765 test_expect_success 'stdin -z fails delete with no ref' '
766 printf $F "delete " >stdin &&
767 test_must_fail git update-ref -z --stdin <stdin 2>err &&
768 - grep "fatal: delete line missing <ref>" err
768 + grep "fatal: delete: missing <ref>" err
769 '
770
771 test_expect_success 'stdin -z fails delete with bad ref name' '
@@ -868,7 +868,7 @@ test_expect_success 'stdin -z create ref fails with bad new value' '
868 test_expect_success 'stdin -z create ref fails with empty new value' '
869 printf $F "create $c" "" >stdin &&
870 test_must_fail git update-ref -z --stdin <stdin 2>err &&
871 - grep "fatal: create $c missing <newvalue>" err &&
871 + grep "fatal: create $c: missing <newvalue>" err &&
872 test_must_fail git rev-parse --verify -q $c
873 '
874
@@ -892,7 +892,7 @@ test_expect_success 'stdin -z delete ref fails with wrong old value' '
892 test_expect_success 'stdin -z delete ref fails with zero old value' '
893 printf $F "delete $a" "$Z" >stdin &&
894 test_must_fail git update-ref -z --stdin <stdin 2>err &&
895 - grep "fatal: delete $a given zero <oldvalue>" err &&
895 + grep "fatal: delete $a: zero <oldvalue>" err &&
896 git rev-parse $m >expect &&
897 git rev-parse $a >actual &&
898 test_cmp expect actual