Skip to content

Commit

Permalink
upload-pack: Improve error message when bad ref requested
Browse files Browse the repository at this point in the history
When printing an error message saying a ref was requested that we do not
have, only print that ref, rather than the ref and everything sent to us
on the same packet line (e.g. protocol support specifications).

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Elijah Newren authored and Junio C Hamano committed Aug 2, 2010
1 parent b73f294 commit 9f9aa76
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions t/t5530-upload-pack-error.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ test_expect_success 'upload-pack fails due to error in rev-list' '
grep "bad tree object" output.err
'

test_expect_success 'upload-pack error message when bad ref requested' '
printf "0045want %s multi_ack_detailed\n00000009done\n0000" \
"deadbeefdeadbeefdeadbeefdeadbeefdeadbeef" >input &&
test_must_fail git upload-pack . <input >output 2>output.err &&
grep -q "not our ref" output.err &&
! grep -q multi_ack_detailed output.err
'

test_expect_success 'upload-pack fails due to error in pack-objects enumeration' '
printf "0032want %s\n00000009done\n0000" \
Expand Down
3 changes: 2 additions & 1 deletion upload-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,8 @@ static void receive_needs(void)
*/
o = lookup_object(sha1_buf);
if (!o || !(o->flags & OUR_REF))
die("git upload-pack: not our ref %s", line+5);
die("git upload-pack: not our ref %s",
sha1_to_hex(sha1_buf));
if (!(o->flags & WANTED)) {
o->flags |= WANTED;
add_object_array(o, NULL, &want_obj);
Expand Down

0 comments on commit 9f9aa76

Please sign in to comment.