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>
This commit is contained in:

committed by
Junio C Hamano

parent
7b38efad5e
commit
2ae2e2a1ca
@ -1676,7 +1676,7 @@ static int write_ref_to_lockfile(struct ref_lock *lock,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fd = get_lock_file_fd(&lock->lk);
|
fd = get_lock_file_fd(&lock->lk);
|
||||||
if (write_in_full(fd, oid_to_hex(oid), GIT_SHA1_HEXSZ) < 0 ||
|
if (write_in_full(fd, oid_to_hex(oid), the_hash_algo->hexsz) < 0 ||
|
||||||
write_in_full(fd, &term, 1) < 0 ||
|
write_in_full(fd, &term, 1) < 0 ||
|
||||||
close_ref_gently(lock) < 0) {
|
close_ref_gently(lock) < 0) {
|
||||||
strbuf_addf(err,
|
strbuf_addf(err,
|
||||||
@ -3070,7 +3070,7 @@ static int files_reflog_expire(struct ref_store *ref_store,
|
|||||||
rollback_lock_file(&reflog_lock);
|
rollback_lock_file(&reflog_lock);
|
||||||
} else if (update &&
|
} else if (update &&
|
||||||
(write_in_full(get_lock_file_fd(&lock->lk),
|
(write_in_full(get_lock_file_fd(&lock->lk),
|
||||||
oid_to_hex(&cb.last_kept_oid), GIT_SHA1_HEXSZ) < 0 ||
|
oid_to_hex(&cb.last_kept_oid), the_hash_algo->hexsz) < 0 ||
|
||||||
write_str_in_full(get_lock_file_fd(&lock->lk), "\n") < 0 ||
|
write_str_in_full(get_lock_file_fd(&lock->lk), "\n") < 0 ||
|
||||||
close_ref_gently(lock) < 0)) {
|
close_ref_gently(lock) < 0)) {
|
||||||
status |= error("couldn't write %s",
|
status |= error("couldn't write %s",
|
||||||
|
Reference in New Issue
Block a user