sha1-file: modernize loose object file functions

The loose object access code in sha1-file.c is some of the oldest in
Git, and could use some modernizing. It mostly uses "unsigned char *"
for object ids, which these days should be "struct object_id".

It also uses the term "sha1_file" in many functions, which is confusing.
The term "loose_objects" is much better. It clearly distinguishes
them from packed objects (which didn't even exist back when the name
"sha1_file" came into being). And it also distinguishes it from the
checksummed-file concept in csum-file.c (which until recently was
actually called "struct sha1file"!).

This patch converts the functions {open,close,map,stat}_sha1_file() into
open_loose_object(), etc, and switches their sha1 arguments for
object_id structs. Similarly, path functions like fill_sha1_path()
become fill_loose_path() and use object_ids.

The function sha1_loose_object_info() already says "loose", so we can
just drop the "sha1" (and teach it to use object_id).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King
2019-01-07 03:35:42 -05:00
committed by Junio C Hamano
parent f0be0db13d
commit 514c5fdd03
5 changed files with 51 additions and 48 deletions

View File

@@ -338,8 +338,8 @@ static struct stream_vtbl loose_vtbl = {
static open_method_decl(loose)
{
st->u.loose.mapped = map_sha1_file(the_repository,
oid->hash, &st->u.loose.mapsize);
st->u.loose.mapped = map_loose_object(the_repository,
oid, &st->u.loose.mapsize);
if (!st->u.loose.mapped)
return -1;
if ((unpack_sha1_header(&st->z,