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 <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
15be4a5d38
commit
e82caf384b
@ -219,8 +219,8 @@ static void parse_args(struct pathspec *pathspec,
|
||||
* has to be unambiguous. If there is a single argument, it
|
||||
* can not be a tree
|
||||
*/
|
||||
else if ((!argv[1] && !get_sha1_committish(argv[0], unused.hash)) ||
|
||||
(argv[1] && !get_sha1_treeish(argv[0], unused.hash))) {
|
||||
else if ((!argv[1] && !get_oid_committish(argv[0], &unused)) ||
|
||||
(argv[1] && !get_oid_treeish(argv[0], &unused))) {
|
||||
/*
|
||||
* Ok, argv[0] looks like a commit/tree; it should not
|
||||
* be a filename.
|
||||
@ -310,13 +310,13 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
|
||||
|
||||
load_submodule_cache();
|
||||
|
||||
unborn = !strcmp(rev, "HEAD") && get_sha1("HEAD", oid.hash);
|
||||
unborn = !strcmp(rev, "HEAD") && get_oid("HEAD", &oid);
|
||||
if (unborn) {
|
||||
/* reset on unborn branch: treat as reset to empty tree */
|
||||
hashcpy(oid.hash, EMPTY_TREE_SHA1_BIN);
|
||||
} else if (!pathspec.nr) {
|
||||
struct commit *commit;
|
||||
if (get_sha1_committish(rev, oid.hash))
|
||||
if (get_oid_committish(rev, &oid))
|
||||
die(_("Failed to resolve '%s' as a valid revision."), rev);
|
||||
commit = lookup_commit_reference(&oid);
|
||||
if (!commit)
|
||||
@ -324,7 +324,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
|
||||
oidcpy(&oid, &commit->object.oid);
|
||||
} else {
|
||||
struct tree *tree;
|
||||
if (get_sha1_treeish(rev, oid.hash))
|
||||
if (get_oid_treeish(rev, &oid))
|
||||
die(_("Failed to resolve '%s' as a valid tree."), rev);
|
||||
tree = parse_tree_indirect(&oid);
|
||||
if (!tree)
|
||||
|
Reference in New Issue
Block a user