From e82caf384bb3c7f41ec5419de04e6493d7b0f4a5 Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Thu, 13 Jul 2017 23:49:28 +0000 Subject: sha1_name: convert get_sha1* to get_oid* Now that all the callers of get_sha1 directly or indirectly use struct object_id, rename the functions starting with get_sha1 to start with get_oid. Convert the internals in sha1_name.c to use struct object_id as well, and eliminate explicit length checks where possible. Convert a use of 40 in get_oid_basic to GIT_SHA1_HEXSZ. Outside of sha1_name.c and cache.h, this transition was made with the following semantic patch: @@ expression E1, E2; @@ - get_sha1(E1, E2.hash) + get_oid(E1, &E2) @@ expression E1, E2; @@ - get_sha1(E1, E2->hash) + get_oid(E1, E2) @@ expression E1, E2; @@ - get_sha1_committish(E1, E2.hash) + get_oid_committish(E1, &E2) @@ expression E1, E2; @@ - get_sha1_committish(E1, E2->hash) + get_oid_committish(E1, E2) @@ expression E1, E2; @@ - get_sha1_treeish(E1, E2.hash) + get_oid_treeish(E1, &E2) @@ expression E1, E2; @@ - get_sha1_treeish(E1, E2->hash) + get_oid_treeish(E1, E2) @@ expression E1, E2; @@ - get_sha1_commit(E1, E2.hash) + get_oid_commit(E1, &E2) @@ expression E1, E2; @@ - get_sha1_commit(E1, E2->hash) + get_oid_commit(E1, E2) @@ expression E1, E2; @@ - get_sha1_tree(E1, E2.hash) + get_oid_tree(E1, &E2) @@ expression E1, E2; @@ - get_sha1_tree(E1, E2->hash) + get_oid_tree(E1, E2) @@ expression E1, E2; @@ - get_sha1_blob(E1, E2.hash) + get_oid_blob(E1, &E2) @@ expression E1, E2; @@ - get_sha1_blob(E1, E2->hash) + get_oid_blob(E1, E2) @@ expression E1, E2, E3, E4; @@ - get_sha1_with_context(E1, E2, E3.hash, E4) + get_oid_with_context(E1, E2, &E3, E4) @@ expression E1, E2, E3, E4; @@ - get_sha1_with_context(E1, E2, E3->hash, E4) + get_oid_with_context(E1, E2, E3, E4) Signed-off-by: brian m. carlson Signed-off-by: Junio C Hamano --- builtin/cat-file.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'builtin/cat-file.c') diff --git a/builtin/cat-file.c b/builtin/cat-file.c index 96b786e489..1f035fb550 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -63,8 +63,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name, if (unknown_type) flags |= OBJECT_INFO_ALLOW_UNKNOWN_TYPE; - if (get_sha1_with_context(obj_name, GET_SHA1_RECORD_PATH, - oid.hash, &obj_context)) + if (get_oid_with_context(obj_name, GET_SHA1_RECORD_PATH, + &oid, &obj_context)) die("Not a valid object name %s", obj_name); if (!path) @@ -364,7 +364,7 @@ static void batch_one_object(const char *obj_name, struct batch_options *opt, int flags = opt->follow_symlinks ? GET_SHA1_FOLLOW_SYMLINKS : 0; enum follow_symlinks_result result; - result = get_sha1_with_context(obj_name, flags, data->oid.hash, &ctx); + result = get_oid_with_context(obj_name, flags, &data->oid, &ctx); if (result != FOUND) { switch (result) { case MISSING_OBJECT: -- cgit v1.2.3