Commit d1c92a95 by Edward Thomson

refdb: handle SHA256 references

parent 93e55a02
...@@ -102,13 +102,16 @@ int git_parse_advance_digit(int64_t *out, git_parse_ctx *ctx, int base) ...@@ -102,13 +102,16 @@ int git_parse_advance_digit(int64_t *out, git_parse_ctx *ctx, int base)
return 0; return 0;
} }
int git_parse_advance_oid(git_oid *out, git_parse_ctx *ctx) int git_parse_advance_oid(git_oid *out, git_parse_ctx *ctx, git_oid_t oid_type)
{ {
if (ctx->line_len < GIT_OID_SHA1_HEXSIZE) size_t oid_hexsize = git_oid_hexsize(oid_type);
GIT_ASSERT(oid_hexsize);
if (ctx->line_len < oid_hexsize)
return -1; return -1;
if ((git_oid__fromstrn(out, ctx->line, GIT_OID_SHA1_HEXSIZE, GIT_OID_SHA1)) < 0) if ((git_oid__fromstrn(out, ctx->line, oid_hexsize, oid_type)) < 0)
return -1; return -1;
git_parse_advance_chars(ctx, GIT_OID_SHA1_HEXSIZE); git_parse_advance_chars(ctx, oid_hexsize);
return 0; return 0;
} }
......
...@@ -50,7 +50,7 @@ int git_parse_advance_expected( ...@@ -50,7 +50,7 @@ int git_parse_advance_expected(
int git_parse_advance_ws(git_parse_ctx *ctx); int git_parse_advance_ws(git_parse_ctx *ctx);
int git_parse_advance_nl(git_parse_ctx *ctx); int git_parse_advance_nl(git_parse_ctx *ctx);
int git_parse_advance_digit(int64_t *out, git_parse_ctx *ctx, int base); int git_parse_advance_digit(int64_t *out, git_parse_ctx *ctx, int base);
int git_parse_advance_oid(git_oid *out, git_parse_ctx *ctx); int git_parse_advance_oid(git_oid *out, git_parse_ctx *ctx, git_oid_t oid_type);
enum GIT_PARSE_PEEK_FLAGS { enum GIT_PARSE_PEEK_FLAGS {
GIT_PARSE_PEEK_SKIP_WHITESPACE = (1 << 0) GIT_PARSE_PEEK_SKIP_WHITESPACE = (1 << 0)
......
...@@ -1949,9 +1949,9 @@ static int reflog_parse(git_reflog *log, const char *buf, size_t buf_size) ...@@ -1949,9 +1949,9 @@ static int reflog_parse(git_reflog *log, const char *buf, size_t buf_size)
entry->committer = git__calloc(1, sizeof(*entry->committer)); entry->committer = git__calloc(1, sizeof(*entry->committer));
GIT_ERROR_CHECK_ALLOC(entry->committer); GIT_ERROR_CHECK_ALLOC(entry->committer);
if (git_parse_advance_oid(&entry->oid_old, &parser) < 0 || if (git_parse_advance_oid(&entry->oid_old, &parser, log->oid_type) < 0 ||
git_parse_advance_expected(&parser, " ", 1) < 0 || git_parse_advance_expected(&parser, " ", 1) < 0 ||
git_parse_advance_oid(&entry->oid_cur, &parser) < 0) git_parse_advance_oid(&entry->oid_cur, &parser, log->oid_type) < 0)
goto next; goto next;
sig = parser.line; sig = parser.line;
......
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