diff options
author | Jeff King <peff@peff.net> | 2019-01-07 03:35:42 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-01-08 09:40:19 -0800 |
commit | 514c5fdd03b914c72a91bb420e46bdc8886940cf (patch) | |
tree | e2c87cab6b656703a589106307bbbce05f8561b4 /object-store.h | |
parent | http: use struct object_id instead of bare sha1 (diff) | |
download | tgif-514c5fdd03b914c72a91bb420e46bdc8886940cf.tar.xz |
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>
Diffstat (limited to 'object-store.h')
-rw-r--r-- | object-store.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/object-store.h b/object-store.h index e16aa38cae..139feb75b2 100644 --- a/object-store.h +++ b/object-store.h @@ -154,11 +154,13 @@ void raw_object_store_clear(struct raw_object_store *o); /* * Put in `buf` the name of the file in the local object database that - * would be used to store a loose object with the specified sha1. + * would be used to store a loose object with the specified oid. */ -const char *loose_object_path(struct repository *r, struct strbuf *buf, const unsigned char *sha1); +const char *loose_object_path(struct repository *r, struct strbuf *buf, + const struct object_id *oid); -void *map_sha1_file(struct repository *r, const unsigned char *sha1, unsigned long *size); +void *map_loose_object(struct repository *r, const struct object_id *oid, + unsigned long *size); extern void *read_object_file_extended(const struct object_id *oid, enum object_type *type, |