Skip to content

Commit 36df49c

Browse files
committed
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 parent c7b189b commit 36df49c

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

include/git2/deprecated.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,8 @@ GIT_EXTERN(int) git_diff_format_email_options_init(
436436
#define GITERR_WORKTREE GIT_ERROR_WORKTREE
437437
#define GITERR_SHA1 GIT_ERROR_SHA1
438438

439+
#define GIT_ERROR_SHA1 GIT_ERROR_SHA
440+
439441
/**
440442
* Return the last `git_error` object that was generated for the
441443
* current thread. This is an alias of `git_error_last` and is

include/git2/errors.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ typedef enum {
106106
GIT_ERROR_FILESYSTEM,
107107
GIT_ERROR_PATCH,
108108
GIT_ERROR_WORKTREE,
109-
GIT_ERROR_SHA1,
109+
GIT_ERROR_SHA,
110110
GIT_ERROR_HTTP,
111111
GIT_ERROR_INTERNAL
112112
} git_error_t;

src/util/hash/collisiondetect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ int git_hash_sha1_final(unsigned char *out, git_hash_sha1_ctx *ctx)
4040
{
4141
GIT_ASSERT_ARG(ctx);
4242
if (SHA1DCFinal(out, &ctx->c)) {
43-
git_error_set(GIT_ERROR_SHA1, "SHA1 collision attack detected");
43+
git_error_set(GIT_ERROR_SHA, "SHA1 collision attack detected");
4444
return -1;
4545
}
4646

src/util/hash/openssl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ int git_hash_sha1_init(git_hash_sha1_ctx *ctx)
2727
GIT_ASSERT_ARG(ctx);
2828

2929
if (SHA1_Init(&ctx->c) != 1) {
30-
git_error_set(GIT_ERROR_SHA1, "hash_openssl: failed to initialize hash context");
30+
git_error_set(GIT_ERROR_SHA, "hash_openssl: failed to initialize hash context");
3131
return -1;
3232
}
3333

@@ -39,7 +39,7 @@ int git_hash_sha1_update(git_hash_sha1_ctx *ctx, const void *data, size_t len)
3939
GIT_ASSERT_ARG(ctx);
4040

4141
if (SHA1_Update(&ctx->c, data, len) != 1) {
42-
git_error_set(GIT_ERROR_SHA1, "hash_openssl: failed to update hash");
42+
git_error_set(GIT_ERROR_SHA, "hash_openssl: failed to update hash");
4343
return -1;
4444
}
4545

@@ -51,7 +51,7 @@ int git_hash_sha1_final(unsigned char *out, git_hash_sha1_ctx *ctx)
5151
GIT_ASSERT_ARG(ctx);
5252

5353
if (SHA1_Final(out, &ctx->c) != 1) {
54-
git_error_set(GIT_ERROR_SHA1, "hash_openssl: failed to finalize hash");
54+
git_error_set(GIT_ERROR_SHA, "hash_openssl: failed to finalize hash");
5555
return -1;
5656
}
5757

src/util/hash/win32.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ GIT_INLINE(int) hash_cng_prov_init(void)
3535

3636
/* Only use CNG on Windows 2008 / Vista SP1 or better (Windows 6.0 SP1) */
3737
if (!git_has_win32_version(6, 0, 1)) {
38-
git_error_set(GIT_ERROR_SHA1, "CryptoNG is not supported on this platform");
38+
git_error_set(GIT_ERROR_SHA, "CryptoNG is not supported on this platform");
3939
return -1;
4040
}
4141

@@ -45,7 +45,7 @@ GIT_INLINE(int) hash_cng_prov_init(void)
4545
StringCchCat(dll_path, MAX_PATH, "\\") < 0 ||
4646
StringCchCat(dll_path, MAX_PATH, GIT_HASH_CNG_DLL_NAME) < 0 ||
4747
(hash_prov.prov.cng.dll = LoadLibrary(dll_path)) == NULL) {
48-
git_error_set(GIT_ERROR_SHA1, "CryptoNG library could not be loaded");
48+
git_error_set(GIT_ERROR_SHA, "CryptoNG library could not be loaded");
4949
return -1;
5050
}
5151

0 commit comments

Comments
 (0)