diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2023-04-22 23:09:32 +0100 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-22 23:09:32 +0100 | 
| commit | 8a62616f43fe5ea37d41296f40293ff97aa88cfa (patch) | |
| tree | edb5683195bb8989814ca610e6745745b361efb9 /src/libgit2/parse.c | |
| parent | abb0b313172d1b4477fe0c6e88102ce4bb8db90c (diff) | |
| parent | b899fda3d88dc92f50e73544fb7524a1c3c70354 (diff) | |
| download | libgit2-8a62616f43fe5ea37d41296f40293ff97aa88cfa.tar.gz | |
Merge pull request #6549 from libgit2/ethomson/sha256_experimental
sha256: less hardcoded SHA1 types and lengths
Diffstat (limited to 'src/libgit2/parse.c')
| -rw-r--r-- | src/libgit2/parse.c | 11 | 
1 files changed, 7 insertions, 4 deletions
diff --git a/src/libgit2/parse.c b/src/libgit2/parse.c index 55d3cb10e..9eb86a3f5 100644 --- a/src/libgit2/parse.c +++ b/src/libgit2/parse.c @@ -102,13 +102,16 @@ int git_parse_advance_digit(int64_t *out, git_parse_ctx *ctx, int base)  	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; -	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; -	git_parse_advance_chars(ctx, GIT_OID_SHA1_HEXSIZE); +	git_parse_advance_chars(ctx, oid_hexsize);  	return 0;  }  | 
