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>
brian m. carlson committed
Jul 16, 2018 at 01:27 UTC
2ae2e2a1ca6e0042ff163920de95884e8ff45142
1 file changed
+2
-2
refs/files-backend.c
+2
-2
@@ -1676,7 +1676,7 @@ static int write_ref_to_lockfile(struct ref_lock *lock,
1676
return -1;
1677
}
1678
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 ||
1680
write_in_full(fd, &term, 1) < 0 ||
1681
close_ref_gently(lock) < 0) {
1682
strbuf_addf(err,
@@ -3070,7 +3070,7 @@ static int files_reflog_expire(struct ref_store *ref_store,
3070
rollback_lock_file(&reflog_lock);
3071
} else if (update &&
3072
(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 ||
3074
write_str_in_full(get_lock_file_fd(&lock->lk), "\n") < 0 ||
3075
close_ref_gently(lock) < 0)) {
3076
status |= error("couldn't write %s",