Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2007-01-23 08:55:18 +0300
committerJunio C Hamano <junkio@cox.net>2007-01-25 05:08:02 +0300
commita69e542989d0aa1576a4b6820454b9b0d2636796 (patch)
tree1793fa49a60bc1bb827755100f4e2baca5238c55 /receive-pack.c
parent196055c2dbbd8ee41b4afb1c2d035d0c05c963b8 (diff)
Refactor the pack header reading function out of receive-pack.c
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'receive-pack.c')
-rw-r--r--receive-pack.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/receive-pack.c b/receive-pack.c
index 6333f00c6e..b3a4552692 100644
--- a/receive-pack.c
+++ b/receive-pack.c
@@ -250,20 +250,22 @@ static void read_head_info(void)
static const char *parse_pack_header(struct pack_header *hdr)
{
- char *c = (char*)hdr;
- ssize_t remaining = sizeof(struct pack_header);
- do {
- ssize_t r = xread(0, c, remaining);
- if (r <= 0)
- return "eof before pack header was fully read";
- remaining -= r;
- c += r;
- } while (remaining > 0);
- if (hdr->hdr_signature != htonl(PACK_SIGNATURE))
+ switch (read_pack_header(0, hdr)) {
+ case PH_ERROR_EOF:
+ return "eof before pack header was fully read";
+
+ case PH_ERROR_PACK_SIGNATURE:
return "protocol error (pack signature mismatch detected)";
- if (!pack_version_ok(hdr->hdr_version))
+
+ case PH_ERROR_PROTOCOL:
return "protocol error (pack version unsupported)";
- return NULL;
+
+ default:
+ return "unknown error in parse_pack_header";
+
+ case 0:
+ return NULL;
+ }
}
static const char *pack_lockfile;