From 514c5fdd03b914c72a91bb420e46bdc8886940cf Mon Sep 17 00:00:00 2001 From: Jeff King Date: Mon, 7 Jan 2019 03:35:42 -0500 Subject: 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 Signed-off-by: Junio C Hamano --- streaming.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'streaming.c') diff --git a/streaming.c b/streaming.c index ac7c7a22f9..9049146bc1 100644 --- a/streaming.c +++ b/streaming.c @@ -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, -- cgit v1.2.3 From 00a7760e81e067cdfb6113e02d141d508529ffc7 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Mon, 7 Jan 2019 03:37:02 -0500 Subject: sha1-file: modernize loose header/stream functions As with the open/map/close functions for loose objects that were recently converted, the functions for parsing the loose object stream use the name "sha1" and a bare "unsigned char *". Let's fix that so that unpack_sha1_header() becomes unpack_loose_header(), etc. These conversions are less clear-cut than the file access functions. You could argue that the they are parsing Git's canonical object format (i.e., "type size\0contents", over which we compute the hash), which is not strictly tied to loose storage. But in practice these functions are used only for loose objects, and using the term "loose_header" (instead of "object_header") distinguishes it from the object header found in packfiles (which contains the same information in a different format). Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- streaming.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'streaming.c') diff --git a/streaming.c b/streaming.c index 9049146bc1..998e6285d7 100644 --- a/streaming.c +++ b/streaming.c @@ -342,12 +342,12 @@ static open_method_decl(loose) oid, &st->u.loose.mapsize); if (!st->u.loose.mapped) return -1; - if ((unpack_sha1_header(&st->z, - st->u.loose.mapped, - st->u.loose.mapsize, - st->u.loose.hdr, - sizeof(st->u.loose.hdr)) < 0) || - (parse_sha1_header(st->u.loose.hdr, &st->size) < 0)) { + if ((unpack_loose_header(&st->z, + st->u.loose.mapped, + st->u.loose.mapsize, + st->u.loose.hdr, + sizeof(st->u.loose.hdr)) < 0) || + (parse_loose_header(st->u.loose.hdr, &st->size) < 0)) { git_inflate_end(&st->z); munmap(st->u.loose.mapped, st->u.loose.mapsize); return -1; -- cgit v1.2.3