summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-05-04 18:08:10 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-05-05 17:17:56 (GMT)
commit1427a7ff70bce0c1040831d5d674c83ebcda6d7d (patch)
treeb2ae32819798ef09ab9222ebe19fc0239e4ba2b7 /sha1_file.c
parent383c3427afa3201eb05e931825c5c2f20616b58b (diff)
downloadgit-1427a7ff70bce0c1040831d5d674c83ebcda6d7d.zip
git-1427a7ff70bce0c1040831d5d674c83ebcda6d7d.tar.gz
git-1427a7ff70bce0c1040831d5d674c83ebcda6d7d.tar.bz2
write_sha1_file(): do not use a separate sha1[] array
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>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/sha1_file.c b/sha1_file.c
index dc940e6..5d32075 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2945,9 +2945,8 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
return move_temp_to_file(tmp_file, filename);
}
-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;
@@ -2955,8 +2954,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 (has_sha1_file(sha1))
return 0;
return write_loose_object(sha1, hdr, hdrlen, buf, len, 0);