sha: GIT_ERROR_SHA1 is deprecated in favor of GIT_ERROR_SHA The more generic GIT_ERROR_SHA allows for SHA256 errors as well as SHA1.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
diff --git a/include/git2/deprecated.h b/include/git2/deprecated.h
index f73d7da..c32abee 100644
--- a/include/git2/deprecated.h
+++ b/include/git2/deprecated.h
@@ -436,6 +436,8 @@ GIT_EXTERN(int) git_diff_format_email_options_init(
#define GITERR_WORKTREE GIT_ERROR_WORKTREE
#define GITERR_SHA1 GIT_ERROR_SHA1
+#define GIT_ERROR_SHA1 GIT_ERROR_SHA
+
/**
* Return the last `git_error` object that was generated for the
* current thread. This is an alias of `git_error_last` and is
diff --git a/include/git2/errors.h b/include/git2/errors.h
index 62f3635..aba6d75 100644
--- a/include/git2/errors.h
+++ b/include/git2/errors.h
@@ -106,7 +106,7 @@ typedef enum {
GIT_ERROR_FILESYSTEM,
GIT_ERROR_PATCH,
GIT_ERROR_WORKTREE,
- GIT_ERROR_SHA1,
+ GIT_ERROR_SHA,
GIT_ERROR_HTTP,
GIT_ERROR_INTERNAL
} git_error_t;
diff --git a/src/util/hash/collisiondetect.c b/src/util/hash/collisiondetect.c
index ec7059c..c51a402 100644
--- a/src/util/hash/collisiondetect.c
+++ b/src/util/hash/collisiondetect.c
@@ -40,7 +40,7 @@ int git_hash_sha1_final(unsigned char *out, git_hash_sha1_ctx *ctx)
{
GIT_ASSERT_ARG(ctx);
if (SHA1DCFinal(out, &ctx->c)) {
- git_error_set(GIT_ERROR_SHA1, "SHA1 collision attack detected");
+ git_error_set(GIT_ERROR_SHA, "SHA1 collision attack detected");
return -1;
}
diff --git a/src/util/hash/openssl.c b/src/util/hash/openssl.c
index 64bf99b..2011edf 100644
--- a/src/util/hash/openssl.c
+++ b/src/util/hash/openssl.c
@@ -27,7 +27,7 @@ int git_hash_sha1_init(git_hash_sha1_ctx *ctx)
GIT_ASSERT_ARG(ctx);
if (SHA1_Init(&ctx->c) != 1) {
- git_error_set(GIT_ERROR_SHA1, "hash_openssl: failed to initialize hash context");
+ git_error_set(GIT_ERROR_SHA, "hash_openssl: failed to initialize hash context");
return -1;
}
@@ -39,7 +39,7 @@ int git_hash_sha1_update(git_hash_sha1_ctx *ctx, const void *data, size_t len)
GIT_ASSERT_ARG(ctx);
if (SHA1_Update(&ctx->c, data, len) != 1) {
- git_error_set(GIT_ERROR_SHA1, "hash_openssl: failed to update hash");
+ git_error_set(GIT_ERROR_SHA, "hash_openssl: failed to update hash");
return -1;
}
@@ -51,7 +51,7 @@ int git_hash_sha1_final(unsigned char *out, git_hash_sha1_ctx *ctx)
GIT_ASSERT_ARG(ctx);
if (SHA1_Final(out, &ctx->c) != 1) {
- git_error_set(GIT_ERROR_SHA1, "hash_openssl: failed to finalize hash");
+ git_error_set(GIT_ERROR_SHA, "hash_openssl: failed to finalize hash");
return -1;
}
diff --git a/src/util/hash/win32.c b/src/util/hash/win32.c
index b89dfba..0e93593 100644
--- a/src/util/hash/win32.c
+++ b/src/util/hash/win32.c
@@ -35,7 +35,7 @@ GIT_INLINE(int) hash_cng_prov_init(void)
/* Only use CNG on Windows 2008 / Vista SP1 or better (Windows 6.0 SP1) */
if (!git_has_win32_version(6, 0, 1)) {
- git_error_set(GIT_ERROR_SHA1, "CryptoNG is not supported on this platform");
+ git_error_set(GIT_ERROR_SHA, "CryptoNG is not supported on this platform");
return -1;
}
@@ -45,7 +45,7 @@ GIT_INLINE(int) hash_cng_prov_init(void)
StringCchCat(dll_path, MAX_PATH, "\\") < 0 ||
StringCchCat(dll_path, MAX_PATH, GIT_HASH_CNG_DLL_NAME) < 0 ||
(hash_prov.prov.cng.dll = LoadLibrary(dll_path)) == NULL) {
- git_error_set(GIT_ERROR_SHA1, "CryptoNG library could not be loaded");
+ git_error_set(GIT_ERROR_SHA, "CryptoNG library could not be loaded");
return -1;
}