update-ref --stdin: improve the error message for unexpected EOF
Distinguish this error from the error that an argument is missing for another reason. 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
726f69166ff0ac3fef0a9a0241f09a7d9f0fa48f
2 files changed
+8
-8
builtin/update-ref.c
+2
-2
@@ -178,8 +178,8 @@ static int parse_next_sha1(struct strbuf *input, const char **next,
178
179
eof:
180
die(flags & PARSE_SHA1_OLD ?
181
- "%s %s missing <oldvalue>" :
182
- "%s %s missing <newvalue>",
181
+ "%s %s: unexpected end of input when reading <oldvalue>" :
182
+ "%s %s: unexpected end of input when reading <newvalue>",
183
command, refname);
184
}
185
t/t1400-update-ref.sh
+6
-6
@@ -709,7 +709,7 @@ test_expect_success 'stdin -z fails create with bad ref name' '
709
test_expect_success 'stdin -z fails create with no new value' '
710
printf $F "create $a" >stdin &&
711
test_must_fail git update-ref -z --stdin <stdin 2>err &&
712
- grep "fatal: create $a missing <newvalue>" err
712
+ grep "fatal: create $a: unexpected end of input when reading <newvalue>" err
713
'
714
715
test_expect_success 'stdin -z fails create with too many arguments' '
@@ -727,7 +727,7 @@ test_expect_success 'stdin -z fails update with no ref' '
727
test_expect_success 'stdin -z fails update with too few args' '
728
printf $F "update $a" "$m" >stdin &&
729
test_must_fail git update-ref -z --stdin <stdin 2>err &&
730
- grep "fatal: update $a missing <oldvalue>" err
730
+ grep "fatal: update $a: unexpected end of input when reading <oldvalue>" err
731
'
732
733
test_expect_success 'stdin -z fails update with bad ref name' '
@@ -747,13 +747,13 @@ test_expect_success 'stdin -z emits warning with empty new value' '
747
test_expect_success 'stdin -z fails update with no new value' '
748
printf $F "update $a" >stdin &&
749
test_must_fail git update-ref -z --stdin <stdin 2>err &&
750
- grep "fatal: update $a missing <newvalue>" err
750
+ grep "fatal: update $a: unexpected end of input when reading <newvalue>" err
751
'
752
753
test_expect_success 'stdin -z fails update with no old value' '
754
printf $F "update $a" "$m" >stdin &&
755
test_must_fail git update-ref -z --stdin <stdin 2>err &&
756
- grep "fatal: update $a missing <oldvalue>" err
756
+ grep "fatal: update $a: unexpected end of input when reading <oldvalue>" err
757
'
758
759
test_expect_success 'stdin -z fails update with too many arguments' '
@@ -777,7 +777,7 @@ test_expect_success 'stdin -z fails delete with bad ref name' '
777
test_expect_success 'stdin -z fails delete with no old value' '
778
printf $F "delete $a" >stdin &&
779
test_must_fail git update-ref -z --stdin <stdin 2>err &&
780
- grep "fatal: delete $a missing <oldvalue>" err
780
+ grep "fatal: delete $a: unexpected end of input when reading <oldvalue>" err
781
'
782
783
test_expect_success 'stdin -z fails delete with too many arguments' '
@@ -795,7 +795,7 @@ test_expect_success 'stdin -z fails verify with too many arguments' '
795
test_expect_success 'stdin -z fails verify with no old value' '
796
printf $F "verify $a" >stdin &&
797
test_must_fail git update-ref -z --stdin <stdin 2>err &&
798
- grep "fatal: verify $a missing <oldvalue>" err
798
+ grep "fatal: verify $a: unexpected end of input when reading <oldvalue>" err
799
'
800
801
test_expect_success 'stdin -z fails option with unknown name' '