Commit adcf638c by Edward Thomson

filebuf: use hashes not oids

The filebuf functions should use hashes directly, not indirectly
using the oid functions.
parent 91365fd8
......@@ -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;
......
......@@ -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);
......
......@@ -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 */
......
......@@ -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));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment