Commit a3bfd284 by Yuang Li

Use GIT_OID_SHA1_HEXSIZE

parent 7c2b1f45
......@@ -133,22 +133,22 @@ int git_grafts_parse(git_grafts *grafts, const char *content, size_t contentlen)
const char *line_start = parser.line, *line_end = parser.line + parser.line_len;
git_oid graft_oid;
if ((error = git_oid_fromstrn(&graft_oid, line_start, GIT_OID_HEXSZ)) < 0) {
if ((error = git_oid_fromstrn(&graft_oid, line_start, GIT_OID_SHA1_HEXSIZE)) < 0) {
git_error_set(GIT_ERROR_GRAFTS, "invalid graft OID at line %" PRIuZ, parser.line_num);
goto error;
}
line_start += GIT_OID_HEXSZ;
line_start += GIT_OID_SHA1_HEXSIZE;
while (line_start < line_end && *line_start == ' ') {
git_oid *id = git_array_alloc(parents);
GIT_ERROR_CHECK_ALLOC(id);
if ((error = git_oid_fromstrn(id, ++line_start, GIT_OID_HEXSZ)) < 0) {
if ((error = git_oid_fromstrn(id, ++line_start, GIT_OID_SHA1_HEXSIZE)) < 0) {
git_error_set(GIT_ERROR_GRAFTS, "invalid parent OID at line %" PRIuZ, parser.line_num);
goto error;
}
line_start += GIT_OID_HEXSZ;
line_start += GIT_OID_SHA1_HEXSIZE;
}
if ((error = git_grafts_add(grafts, &graft_oid, parents)) < 0)
......
......@@ -3372,7 +3372,7 @@ int git_repository__shallow_roots_write(git_repository *repo, git_array_oid_t ro
goto on_error;
git_array_foreach(roots, idx, oid) {
git_filebuf_write(&file, git_oid_tostr_s(oid), GIT_OID_HEXSZ);
git_filebuf_write(&file, git_oid_tostr_s(oid), GIT_OID_SHA1_HEXSIZE);
git_filebuf_write(&file, "\n", 1);
}
......
......@@ -377,10 +377,10 @@ static int shallow_pkt(git_pkt **out, const char *line, size_t len)
line += 7;
len -= 7;
if (len >= GIT_OID_HEXSZ) {
if (len >= GIT_OID_SHA1_HEXSIZE) {
git_oid_fromstr(&pkt->oid, line + 1);
line += GIT_OID_HEXSZ + 1;
len -= GIT_OID_HEXSZ + 1;
line += GIT_OID_SHA1_HEXSIZE + 1;
len -= GIT_OID_SHA1_HEXSIZE + 1;
}
*out = (git_pkt *) pkt;
......@@ -399,10 +399,10 @@ static int unshallow_pkt(git_pkt **out, const char *line, size_t len)
line += 9;
len -= 9;
if (len >= GIT_OID_HEXSZ) {
if (len >= GIT_OID_SHA1_HEXSIZE) {
git_oid_fromstr(&pkt->oid, line + 1);
line += GIT_OID_HEXSZ + 1;
len -= GIT_OID_HEXSZ + 1;
line += GIT_OID_SHA1_HEXSIZE + 1;
len -= GIT_OID_SHA1_HEXSIZE + 1;
}
*out = (git_pkt *) pkt;
......@@ -674,12 +674,12 @@ int git_pkt_buffer_wants(
/* Tell the server about our shallow objects */
for (i = 0; i < git_shallowarray_count(wants->shallow_roots); i++) {
char oid[GIT_OID_HEXSZ];
char oid[GIT_OID_SHA1_HEXSIZE];
git_str shallow_buf = GIT_STR_INIT;
git_oid_fmt(oid, git_shallowarray_get(wants->shallow_roots, i));
git_str_puts(&shallow_buf, "shallow ");
git_str_put(&shallow_buf, oid, GIT_OID_HEXSZ);
git_str_put(&shallow_buf, oid, GIT_OID_SHA1_HEXSIZE);
git_str_putc(&shallow_buf, '\n');
git_str_printf(buf, "%04x%s", (unsigned int)git_str_len(&shallow_buf) + 4, git_str_cstr(&shallow_buf));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment