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 --- revision.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'revision.c') diff --git a/revision.c b/revision.c index 9ff120b30..34bc81adf 100644 --- a/revision.c +++ b/revision.c @@ -1303,7 +1303,7 @@ static int add_parents_only(struct rev_info *revs, const char *arg_, int flags, flags ^= UNINTERESTING | BOTTOM; arg++; } - if (get_sha1_committish(arg, oid.hash)) + if (get_oid_committish(arg, &oid)) return 0; while (1) { it = get_reference(revs, arg, &oid, 0); @@ -1467,8 +1467,8 @@ static int handle_dotdot_1(const char *arg, char *dotdot, if (!*b_name) b_name = "HEAD"; - if (get_sha1_with_context(a_name, oc_flags, a_oid.hash, a_oc) || - get_sha1_with_context(b_name, oc_flags, b_oid.hash, b_oc)) + if (get_oid_with_context(a_name, oc_flags, &a_oid, a_oc) || + get_oid_with_context(b_name, oc_flags, &b_oid, b_oc)) return -1; if (!cant_be_filename) { @@ -1602,7 +1602,7 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi if (revarg_opt & REVARG_COMMITTISH) get_sha1_flags |= GET_SHA1_COMMITTISH; - if (get_sha1_with_context(arg, get_sha1_flags, oid.hash, &oc)) + if (get_oid_with_context(arg, get_sha1_flags, &oid, &oc)) return revs->ignore_missing ? 0 : -1; if (!cant_be_filename) verify_non_filename(revs->prefix, arg); @@ -2321,7 +2321,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s struct object_id oid; struct object *object; struct object_context oc; - if (get_sha1_with_context(revs->def, 0, oid.hash, &oc)) + if (get_oid_with_context(revs->def, 0, &oid, &oc)) diagnose_missing_default(revs->def); object = get_reference(revs, revs->def, &oid, 0); add_pending_object_with_mode(revs, object, revs->def, oc.mode); -- cgit v1.2.1 From 321c89bf5fa937b19800fa97cfe93199b817d34f Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Thu, 13 Jul 2017 23:49:29 +0000 Subject: sha1_name: convert GET_SHA1* flags to GET_OID* Convert the flags for get_oid_with_context and friends to use "OID" instead of "SHA1" in their names. This transform was made by running the following one-liner on the affected files: perl -pi -e 's/GET_SHA1/GET_OID/g' Signed-off-by: brian m. carlson Signed-off-by: Junio C Hamano --- revision.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'revision.c') diff --git a/revision.c b/revision.c index 34bc81adf..913ef8ce3 100644 --- a/revision.c +++ b/revision.c @@ -1453,7 +1453,7 @@ static int handle_dotdot_1(const char *arg, char *dotdot, unsigned int a_flags, b_flags; int symmetric = 0; unsigned int flags_exclude = flags ^ (UNINTERESTING | BOTTOM); - unsigned int oc_flags = GET_SHA1_COMMITTISH | GET_SHA1_RECORD_PATH; + unsigned int oc_flags = GET_OID_COMMITTISH | GET_OID_RECORD_PATH; a_name = arg; if (!*a_name) @@ -1549,7 +1549,7 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi int local_flags; const char *arg = arg_; int cant_be_filename = revarg_opt & REVARG_CANNOT_BE_FILENAME; - unsigned get_sha1_flags = GET_SHA1_RECORD_PATH; + unsigned get_sha1_flags = GET_OID_RECORD_PATH; flags = flags & UNINTERESTING ? flags | BOTTOM : flags & ~BOTTOM; @@ -1600,7 +1600,7 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi } if (revarg_opt & REVARG_COMMITTISH) - get_sha1_flags |= GET_SHA1_COMMITTISH; + get_sha1_flags |= GET_OID_COMMITTISH; if (get_oid_with_context(arg, get_sha1_flags, &oid, &oc)) return revs->ignore_missing ? 0 : -1; -- cgit v1.2.1