Skip to content

Commit adcf638

Browse files
committed
filebuf: use hashes not oids
The filebuf functions should use hashes directly, not indirectly using the oid functions.
1 parent 91365fd commit adcf638

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

src/filebuf.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,9 @@ int git_filebuf_open_withsize(git_filebuf *file, const char *path, int flags, mo
386386
return error;
387387
}
388388

389-
int git_filebuf_hash(git_oid *oid, git_filebuf *file)
389+
int git_filebuf_hash(unsigned char *out, git_filebuf *file)
390390
{
391-
GIT_ASSERT_ARG(oid);
391+
GIT_ASSERT_ARG(out);
392392
GIT_ASSERT_ARG(file);
393393
GIT_ASSERT_ARG(file->compute_digest);
394394

@@ -397,7 +397,7 @@ int git_filebuf_hash(git_oid *oid, git_filebuf *file)
397397
if (verify_last_error(file) < 0)
398398
return -1;
399399

400-
git_hash_final(oid->id, &file->digest);
400+
git_hash_final(out, &file->digest);
401401
git_hash_ctx_cleanup(&file->digest);
402402
file->compute_digest = 0;
403403

src/filebuf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ int git_filebuf_open_withsize(git_filebuf *file, const char *path, int flags, mo
8787
int git_filebuf_commit(git_filebuf *lock);
8888
int git_filebuf_commit_at(git_filebuf *lock, const char *path);
8989
void git_filebuf_cleanup(git_filebuf *lock);
90-
int git_filebuf_hash(git_oid *oid, git_filebuf *file);
90+
int git_filebuf_hash(unsigned char *out, git_filebuf *file);
9191
int git_filebuf_flush(git_filebuf *file);
9292
int git_filebuf_stats(time_t *mtime, size_t *size, git_filebuf *file);
9393

src/index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3080,7 +3080,7 @@ static int write_index(git_oid *checksum, git_index *index, git_filebuf *file)
30803080
return -1;
30813081

30823082
/* get out the hash for all the contents we've appended to the file */
3083-
git_filebuf_hash(&hash_final, file);
3083+
git_filebuf_hash(hash_final.id, file);
30843084
git_oid_cpy(checksum, &hash_final);
30853085

30863086
/* write it at the end of the file */

src/indexer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,7 @@ int git_indexer_commit(git_indexer *idx, git_indexer_progress *stats)
12891289
goto on_error;
12901290

12911291
/* Write out the hash of the idx */
1292-
if (git_filebuf_hash(&trailer_hash, &index_file) < 0)
1292+
if (git_filebuf_hash(trailer_hash.id, &index_file) < 0)
12931293
goto on_error;
12941294

12951295
git_filebuf_write(&index_file, &trailer_hash, sizeof(git_oid));

0 commit comments

Comments
 (0)