Skip to content

Commit 1427a7f

Browse files
committed
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 d6d3f9d (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 <[email protected]>
1 parent 383c342 commit 1427a7f

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

sha1_file.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2945,18 +2945,15 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
29452945
return move_temp_to_file(tmp_file, filename);
29462946
}
29472947

2948-
int write_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *returnsha1)
2948+
int write_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *sha1)
29492949
{
2950-
unsigned char sha1[20];
29512950
char hdr[32];
29522951
int hdrlen;
29532952

29542953
/* Normally if we have it in the pack then we do not bother writing
29552954
* it out into .git/objects/??/?{38} file.
29562955
*/
29572956
write_sha1_file_prepare(buf, len, type, sha1, hdr, &hdrlen);
2958-
if (returnsha1)
2959-
hashcpy(returnsha1, sha1);
29602957
if (has_sha1_file(sha1))
29612958
return 0;
29622959
return write_loose_object(sha1, hdr, hdrlen, buf, len, 0);

0 commit comments

Comments
 (0)