diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2022-07-13 22:25:11 -0400 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2022-07-13 22:50:33 -0400 |
commit | b43567d655b6fbc562a165095a6980d19c4ae278 (patch) | |
tree | ee84020f9f2c9f53a1f11656e2cd1205502cda48 /src/libgit2/oid.c | |
parent | 433a133402fae298f8ee7613bcfd997c2712d269 (diff) | |
download | libgit2-b43567d655b6fbc562a165095a6980d19c4ae278.tar.gz |
sha256: indirection for experimental functions
The experimental function signature is only available when
`GIT_EXPERIMENTAL_SHA256` is enabled.
Diffstat (limited to 'src/libgit2/oid.c')
-rw-r--r-- | src/libgit2/oid.c | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/src/libgit2/oid.c b/src/libgit2/oid.c index cea70c3b3..6cc21641d 100644 --- a/src/libgit2/oid.c +++ b/src/libgit2/oid.c @@ -28,7 +28,7 @@ static int oid_error_invalid(const char *msg) return -1; } -int git_oid_fromstrn( +int git_oid__fromstrn( git_oid *out, const char *str, size_t length, @@ -65,6 +65,26 @@ int git_oid_fromstrn( return 0; } +int git_oid__fromstrp(git_oid *out, const char *str, git_oid_t type) +{ + return git_oid__fromstrn(out, str, strlen(str), type); +} + +int git_oid__fromstr(git_oid *out, const char *str, git_oid_t type) +{ + return git_oid__fromstrn(out, str, git_oid_hexsize(type), type); +} + +#ifdef GIT_EXPERIMENTAL_SHA256 +int git_oid_fromstrn( + git_oid *out, + const char *str, + size_t length, + git_oid_t type) +{ + return git_oid__fromstrn(out, str, length, type); +} + int git_oid_fromstrp(git_oid *out, const char *str, git_oid_t type) { return git_oid_fromstrn(out, str, strlen(str), type); @@ -74,6 +94,25 @@ int git_oid_fromstr(git_oid *out, const char *str, git_oid_t type) { return git_oid_fromstrn(out, str, git_oid_hexsize(type), type); } +#else +int git_oid_fromstrn( + git_oid *out, + const char *str, + size_t length) +{ + return git_oid__fromstrn(out, str, length, GIT_OID_SHA1); +} + +int git_oid_fromstrp(git_oid *out, const char *str) +{ + return git_oid__fromstrn(out, str, strlen(str), GIT_OID_SHA1); +} + +int git_oid_fromstr(git_oid *out, const char *str) +{ + return git_oid__fromstrn(out, str, GIT_OID_SHA1_HEXSIZE, GIT_OID_SHA1); +} +#endif int git_oid_nfmt(char *str, size_t n, const git_oid *oid) { @@ -155,7 +194,7 @@ char *git_oid_tostr(char *out, size_t n, const git_oid *oid) return out; } -int git_oid_fromraw(git_oid *out, const unsigned char *raw, git_oid_t type) +int git_oid__fromraw(git_oid *out, const unsigned char *raw, git_oid_t type) { size_t size; @@ -169,6 +208,18 @@ int git_oid_fromraw(git_oid *out, const unsigned char *raw, git_oid_t type) return 0; } +#ifdef GIT_EXPERIMENTAL_SHA256 +int git_oid_fromraw(git_oid *out, const unsigned char *raw, git_oid_t type) +{ + return git_oid__fromraw(out, raw, type); +} +#else +int git_oid_fromraw(git_oid *out, const unsigned char *raw) +{ + return git_oid__fromraw(out, raw, GIT_OID_SHA1); +} +#endif + int git_oid_cpy(git_oid *out, const git_oid *src) { size_t size; |