From: Elijah Newren Date: Sat, 31 Jul 2010 20:11:46 +0000 (-0600) Subject: upload-pack: Improve error message when bad ref requested X-Git-Tag: v1.7.3-rc0~98 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9f9aa761305e909aca9a46ccb33a5872b36bcb8e;p=git.git upload-pack: Improve error message when bad ref requested 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 Signed-off-by: Junio C Hamano --- diff --git a/t/t5530-upload-pack-error.sh b/t/t5530-upload-pack-error.sh index 044603c26..6b2a5f4a6 100755 --- a/t/t5530-upload-pack-error.sh +++ b/t/t5530-upload-pack-error.sh @@ -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 . 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" \ diff --git a/upload-pack.c b/upload-pack.c index 8f4c718bf..fc79ddef2 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -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);