diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2021-11-21 21:34:17 -0500 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2021-11-22 09:27:59 -0500 |
commit | adcf638cca0a3b38f51a6d7c9b7ce479528cd854 (patch) | |
tree | 21eb7197b52f46f2cd8f7982dbf3ff7e3284f623 | |
parent | 91365fd87c5b09462268eb83b01d3a30d6931c2a (diff) | |
download | libgit2-adcf638cca0a3b38f51a6d7c9b7ce479528cd854.tar.gz |
filebuf: use hashes not oids
The filebuf functions should use hashes directly, not indirectly
using the oid functions.
-rw-r--r-- | src/filebuf.c | 6 | ||||
-rw-r--r-- | src/filebuf.h | 2 | ||||
-rw-r--r-- | src/index.c | 2 | ||||
-rw-r--r-- | src/indexer.c | 2 |
4 files changed, 6 insertions, 6 deletions
diff --git a/src/filebuf.c b/src/filebuf.c index f0bd0004f..eafcba3bd 100644 --- a/src/filebuf.c +++ b/src/filebuf.c @@ -386,9 +386,9 @@ cleanup: return error; } -int git_filebuf_hash(git_oid *oid, git_filebuf *file) +int git_filebuf_hash(unsigned char *out, git_filebuf *file) { - GIT_ASSERT_ARG(oid); + GIT_ASSERT_ARG(out); GIT_ASSERT_ARG(file); GIT_ASSERT_ARG(file->compute_digest); @@ -397,7 +397,7 @@ int git_filebuf_hash(git_oid *oid, git_filebuf *file) if (verify_last_error(file) < 0) return -1; - git_hash_final(oid->id, &file->digest); + git_hash_final(out, &file->digest); git_hash_ctx_cleanup(&file->digest); file->compute_digest = 0; diff --git a/src/filebuf.h b/src/filebuf.h index 9d53bc307..adbb19936 100644 --- a/src/filebuf.h +++ b/src/filebuf.h @@ -87,7 +87,7 @@ int git_filebuf_open_withsize(git_filebuf *file, const char *path, int flags, mo int git_filebuf_commit(git_filebuf *lock); int git_filebuf_commit_at(git_filebuf *lock, const char *path); void git_filebuf_cleanup(git_filebuf *lock); -int git_filebuf_hash(git_oid *oid, git_filebuf *file); +int git_filebuf_hash(unsigned char *out, git_filebuf *file); int git_filebuf_flush(git_filebuf *file); int git_filebuf_stats(time_t *mtime, size_t *size, git_filebuf *file); diff --git a/src/index.c b/src/index.c index 7ade4341f..a2d80bc6e 100644 --- a/src/index.c +++ b/src/index.c @@ -3080,7 +3080,7 @@ static int write_index(git_oid *checksum, git_index *index, git_filebuf *file) return -1; /* get out the hash for all the contents we've appended to the file */ - git_filebuf_hash(&hash_final, file); + git_filebuf_hash(hash_final.id, file); git_oid_cpy(checksum, &hash_final); /* write it at the end of the file */ diff --git a/src/indexer.c b/src/indexer.c index 213ad7581..d9396e058 100644 --- a/src/indexer.c +++ b/src/indexer.c @@ -1289,7 +1289,7 @@ int git_indexer_commit(git_indexer *idx, git_indexer_progress *stats) goto on_error; /* Write out the hash of the idx */ - if (git_filebuf_hash(&trailer_hash, &index_file) < 0) + if (git_filebuf_hash(trailer_hash.id, &index_file) < 0) goto on_error; git_filebuf_write(&index_file, &trailer_hash, sizeof(git_oid)); |