summaryrefslogtreecommitdiff
path: root/refs/files-backend.c
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2018-07-16 01:27:59 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-07-16 21:27:39 (GMT)
commit2ae2e2a1ca6e0042ff163920de95884e8ff45142 (patch)
tree606a1e8becc686ff18fb35051c105874e5bcf8f6 /refs/files-backend.c
parent7b38efad5ed4417defaefe04d64adc7d4b55a66e (diff)
downloadgit-2ae2e2a1ca6e0042ff163920de95884e8ff45142.zip
git-2ae2e2a1ca6e0042ff163920de95884e8ff45142.tar.gz
git-2ae2e2a1ca6e0042ff163920de95884e8ff45142.tar.bz2
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>
Diffstat (limited to 'refs/files-backend.c')
-rw-r--r--refs/files-backend.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c
index a9a066d..c546ffb 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -1676,7 +1676,7 @@ static int write_ref_to_lockfile(struct ref_lock *lock,
return -1;
}
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 ||
close_ref_gently(lock) < 0) {
strbuf_addf(err,
@@ -3070,7 +3070,7 @@ static int files_reflog_expire(struct ref_store *ref_store,
rollback_lock_file(&reflog_lock);
} else if (update &&
(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 ||
close_ref_gently(lock) < 0)) {
status |= error("couldn't write %s",