Skip to content

Commit 2ae2e2a

Browse files
bk2204gitster
authored andcommitted
refs/files-backend: use the_hash_algo for writing refs
In order to ensure we write the correct amount, use the_hash_algo to find the correct number of bytes for the current hash. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 7b38efa commit 2ae2e2a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

refs/files-backend.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,7 +1676,7 @@ static int write_ref_to_lockfile(struct ref_lock *lock,
16761676
return -1;
16771677
}
16781678
fd = get_lock_file_fd(&lock->lk);
1679-
if (write_in_full(fd, oid_to_hex(oid), GIT_SHA1_HEXSZ) < 0 ||
1679+
if (write_in_full(fd, oid_to_hex(oid), the_hash_algo->hexsz) < 0 ||
16801680
write_in_full(fd, &term, 1) < 0 ||
16811681
close_ref_gently(lock) < 0) {
16821682
strbuf_addf(err,
@@ -3070,7 +3070,7 @@ static int files_reflog_expire(struct ref_store *ref_store,
30703070
rollback_lock_file(&reflog_lock);
30713071
} else if (update &&
30723072
(write_in_full(get_lock_file_fd(&lock->lk),
3073-
oid_to_hex(&cb.last_kept_oid), GIT_SHA1_HEXSZ) < 0 ||
3073+
oid_to_hex(&cb.last_kept_oid), the_hash_algo->hexsz) < 0 ||
30743074
write_str_in_full(get_lock_file_fd(&lock->lk), "\n") < 0 ||
30753075
close_ref_gently(lock) < 0)) {
30763076
status |= error("couldn't write %s",

0 commit comments

Comments
 (0)