diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-05-04 11:08:10 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-05-04 11:08:10 -0700 |
commit | 869a8820b4cf6a847e695e8553ab44bd8c40887e (patch) | |
tree | b44a123b5513cb652b14bb7f9422c5f7bb7c3c4f | |
parent | 5833de918765d2f71411589c074356e28fffcf80 (diff) | |
download | git-jc/hash-object-fix.tar.gz |
write_sha1_file(): do not use a separate sha1[] arrayjc/hash-object-fix
In the beginning, write_sha1_file() did not have a way to tell the
caller the name of the object it wrote to the caller. This was
changed in d6d3f9d0 (This implements the new "recursive tree"
write-tree., 2005-04-09) by adding the "returnsha1" parameter to the
function so that the callers who are interested in the value can
optionally pass a pointer to receive it.
It turns out that all callers do want to know the name of the object
it just has written. Nobody passes a NULL to this parameter, hence
it is not necessary to use a separate sha1[] array to receive the
result from write_sha1_file_prepare(), and copy the result to the
returnsha1 supplied by the caller.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | sha1_file.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/sha1_file.c b/sha1_file.c index c8ab069d1b..96e813f32a 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -3002,9 +3002,8 @@ static int freshen_packed_object(const unsigned char *sha1) return find_pack_entry(sha1, &e) && freshen_file(e.p->pack_name); } -int write_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *returnsha1) +int write_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *sha1) { - unsigned char sha1[20]; char hdr[32]; int hdrlen; @@ -3012,8 +3011,6 @@ int write_sha1_file(const void *buf, unsigned long len, const char *type, unsign * it out into .git/objects/??/?{38} file. */ write_sha1_file_prepare(buf, len, type, sha1, hdr, &hdrlen); - if (returnsha1) - hashcpy(returnsha1, sha1); if (freshen_loose_object(sha1) || freshen_packed_object(sha1)) return 0; return write_loose_object(sha1, hdr, hdrlen, buf, len, 0); |