summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2022-01-22 13:14:59 -0500
committerEdward Thomson <ethomson@edwardthomson.com>2022-01-22 14:28:57 -0500
commitac48a68c33735f9f705907479db434ed75435d2b (patch)
treeda71ebfb305d0037e6d47f3379a0f4213d9a261d
parent7c4171f51e1e7b4aa14193930d3eafabd769e5a7 (diff)
downloadlibgit2-ac48a68c33735f9f705907479db434ed75435d2b.tar.gz
config: use a byte array for checksum
-rw-r--r--src/config_file.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/config_file.c b/src/config_file.c
index 43a6ba440..66fcb8ae2 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -19,13 +19,14 @@
#include "regexp.h"
#include "sysdir.h"
#include "wildmatch.h"
+#include "hash.h"
/* Max depth for [include] directives */
#define MAX_INCLUDE_DEPTH 10
typedef struct config_file {
git_futils_filestamp stamp;
- git_oid checksum;
+ unsigned char checksum[GIT_HASH_SHA1_SIZE];
char *path;
git_array_t(struct config_file) includes;
} config_file;
@@ -132,7 +133,7 @@ static int config_file_is_modified(int *modified, config_file *file)
{
config_file *include;
git_str buf = GIT_STR_INIT;
- git_oid hash;
+ unsigned char checksum[GIT_HASH_SHA1_SIZE];
uint32_t i;
int error = 0;
@@ -144,10 +145,10 @@ static int config_file_is_modified(int *modified, config_file *file)
if ((error = git_futils_readbuffer(&buf, file->path)) < 0)
goto out;
- if ((error = git_hash_buf(hash.id, buf.ptr, buf.size, GIT_HASH_ALGORITHM_SHA1)) < 0)
+ if ((error = git_hash_buf(checksum, buf.ptr, buf.size, GIT_HASH_ALGORITHM_SHA1)) < 0)
goto out;
- if (!git_oid_equal(&hash, &file->checksum)) {
+ if (memcmp(checksum, file->checksum, GIT_HASH_SHA1_SIZE) != 0) {
*modified = 1;
goto out;
}
@@ -880,7 +881,7 @@ static int config_file_read(
goto out;
git_futils_filestamp_set_from_stat(&file->stamp, &st);
- if ((error = git_hash_buf(file->checksum.id, contents.ptr, contents.size, GIT_HASH_ALGORITHM_SHA1)) < 0)
+ if ((error = git_hash_buf(file->checksum, contents.ptr, contents.size, GIT_HASH_ALGORITHM_SHA1)) < 0)
goto out;
if ((error = config_file_read_buffer(entries, repo, file, level, depth,