diff options
Diffstat (limited to 'src/libgit2/transports/smart_pkt.c')
-rw-r--r-- | src/libgit2/transports/smart_pkt.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/libgit2/transports/smart_pkt.c b/src/libgit2/transports/smart_pkt.c index b42edd0d6..e679819fa 100644 --- a/src/libgit2/transports/smart_pkt.c +++ b/src/libgit2/transports/smart_pkt.c @@ -12,6 +12,7 @@ #include "netops.h" #include "posix.h" #include "str.h" +#include "oid.h" #include "git2/types.h" #include "git2/errors.h" @@ -53,10 +54,11 @@ static int ack_pkt(git_pkt **out, const char *line, size_t len) line += 4; len -= 4; - if (len < GIT_OID_HEXSZ || git_oid_fromstr(&pkt->oid, line) < 0) + if (len < GIT_OID_SHA1_HEXSIZE || + git_oid__fromstr(&pkt->oid, line, GIT_OID_SHA1) < 0) goto out_err; - line += GIT_OID_HEXSZ; - len -= GIT_OID_HEXSZ; + line += GIT_OID_SHA1_HEXSIZE; + len -= GIT_OID_SHA1_HEXSIZE; if (len && line[0] == ' ') { line++; @@ -222,10 +224,11 @@ static int ref_pkt(git_pkt **out, const char *line, size_t len) GIT_ERROR_CHECK_ALLOC(pkt); pkt->type = GIT_PKT_REF; - if (len < GIT_OID_HEXSZ || git_oid_fromstr(&pkt->head.oid, line) < 0) + if (len < GIT_OID_SHA1_HEXSIZE || + git_oid__fromstr(&pkt->head.oid, line, GIT_OID_SHA1) < 0) goto out_err; - line += GIT_OID_HEXSZ; - len -= GIT_OID_HEXSZ; + line += GIT_OID_SHA1_HEXSIZE; + len -= GIT_OID_SHA1_HEXSIZE; if (git__prefixncmp(line, len, " ")) goto out_err; @@ -530,7 +533,7 @@ int git_pkt_buffer_flush(git_str *buf) static int buffer_want_with_caps(const git_remote_head *head, transport_smart_caps *caps, git_str *buf) { git_str str = GIT_STR_INIT; - char oid[GIT_OID_HEXSZ +1] = {0}; + char oid[GIT_OID_SHA1_HEXSIZE +1] = {0}; size_t len; /* Prefer multi_ack_detailed */ @@ -557,7 +560,7 @@ static int buffer_want_with_caps(const git_remote_head *head, transport_smart_ca if (git_str_oom(&str)) return -1; - len = strlen("XXXXwant ") + GIT_OID_HEXSZ + 1 /* NUL */ + + len = strlen("XXXXwant ") + GIT_OID_SHA1_HEXSIZE + 1 /* NUL */ + git_str_len(&str) + 1 /* LF */; if (len > 0xffff) { @@ -605,7 +608,7 @@ int git_pkt_buffer_wants( } for (; i < count; ++i) { - char oid[GIT_OID_HEXSZ]; + char oid[GIT_OID_SHA1_HEXSIZE]; head = refs[i]; if (head->local) @@ -613,7 +616,7 @@ int git_pkt_buffer_wants( git_oid_fmt(oid, &head->oid); git_str_put(buf, pkt_want_prefix, strlen(pkt_want_prefix)); - git_str_put(buf, oid, GIT_OID_HEXSZ); + git_str_put(buf, oid, GIT_OID_SHA1_HEXSIZE); git_str_putc(buf, '\n'); if (git_str_oom(buf)) return -1; @@ -624,7 +627,7 @@ int git_pkt_buffer_wants( int git_pkt_buffer_have(git_oid *oid, git_str *buf) { - char oidhex[GIT_OID_HEXSZ + 1]; + char oidhex[GIT_OID_SHA1_HEXSIZE + 1]; memset(oidhex, 0x0, sizeof(oidhex)); git_oid_fmt(oidhex, oid); |