From a98e6101f01b6991e780fc0b75f2937615fa84a9 Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Sun, 15 Oct 2017 22:07:07 +0000 Subject: refs: convert resolve_gitlink_ref to struct object_id Convert the declaration and definition of resolve_gitlink_ref to use struct object_id and apply the following semantic patch: @@ expression E1, E2, E3; @@ - resolve_gitlink_ref(E1, E2, E3.hash) + resolve_gitlink_ref(E1, E2, &E3) @@ expression E1, E2, E3; @@ - resolve_gitlink_ref(E1, E2, E3->hash) + resolve_gitlink_ref(E1, E2, E3) Signed-off-by: brian m. carlson Signed-off-by: Junio C Hamano diff --git a/builtin/update-index.c b/builtin/update-index.c index 24f4b28..fefbe60 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -328,7 +328,7 @@ static int process_directory(const char *path, int len, struct stat *st) if (S_ISGITLINK(ce->ce_mode)) { /* Do nothing to the index if there is no HEAD! */ - if (resolve_gitlink_ref(path, "HEAD", oid.hash) < 0) + if (resolve_gitlink_ref(path, "HEAD", &oid) < 0) return 0; return add_one_path(ce, path, len, st); @@ -354,7 +354,7 @@ static int process_directory(const char *path, int len, struct stat *st) } /* No match - should we add it as a gitlink? */ - if (!resolve_gitlink_ref(path, "HEAD", oid.hash)) + if (!resolve_gitlink_ref(path, "HEAD", &oid)) return add_one_path(NULL, path, len, st); /* Error out. */ diff --git a/combine-diff.c b/combine-diff.c index 9e163d5..82f6070 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -1014,7 +1014,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent, elem->mode = canon_mode(st.st_mode); } else if (S_ISDIR(st.st_mode)) { struct object_id oid; - if (resolve_gitlink_ref(elem->path, "HEAD", oid.hash) < 0) + if (resolve_gitlink_ref(elem->path, "HEAD", &oid) < 0) result = grab_blob(&elem->oid, elem->mode, &result_size, NULL, NULL); else diff --git a/diff-lib.c b/diff-lib.c index af4f1b7..d2ea02f 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -50,7 +50,7 @@ static int check_removed(const struct cache_entry *ce, struct stat *st) * a directory --- the blob was removed! */ if (!S_ISGITLINK(ce->ce_mode) && - resolve_gitlink_ref(ce->name, "HEAD", sub.hash)) + resolve_gitlink_ref(ce->name, "HEAD", &sub)) return 1; } return 0; diff --git a/dir.c b/dir.c index a4198ba..f09a31e 100644 --- a/dir.c +++ b/dir.c @@ -1391,7 +1391,7 @@ static enum path_treatment treat_directory(struct dir_struct *dir, break; if (!(dir->flags & DIR_NO_GITLINKS)) { struct object_id oid; - if (resolve_gitlink_ref(dirname, "HEAD", oid.hash) == 0) + if (resolve_gitlink_ref(dirname, "HEAD", &oid) == 0) return path_untracked; } return path_recurse; @@ -2282,7 +2282,7 @@ static int remove_dir_recurse(struct strbuf *path, int flag, int *kept_up) struct object_id submodule_head; if ((flag & REMOVE_DIR_KEEP_NESTED_GIT) && - !resolve_gitlink_ref(path->buf, "HEAD", submodule_head.hash)) { + !resolve_gitlink_ref(path->buf, "HEAD", &submodule_head)) { /* Do not descend and nuke a nested git work tree. */ if (kept_up) *kept_up = 1; diff --git a/read-cache.c b/read-cache.c index 131485b..7766196 100644 --- a/read-cache.c +++ b/read-cache.c @@ -201,7 +201,7 @@ static int ce_compare_gitlink(const struct cache_entry *ce) * * If so, we consider it always to match. */ - if (resolve_gitlink_ref(ce->name, "HEAD", oid.hash) < 0) + if (resolve_gitlink_ref(ce->name, "HEAD", &oid) < 0) return 0; return oidcmp(&oid, &ce->oid); } diff --git a/refs.c b/refs.c index 3748528..90219d6 100644 --- a/refs.c +++ b/refs.c @@ -1498,7 +1498,7 @@ const char *resolve_ref_unsafe(const char *refname, int resolve_flags, } int resolve_gitlink_ref(const char *submodule, const char *refname, - unsigned char *sha1) + struct object_id *oid) { struct ref_store *refs; int flags; @@ -1508,8 +1508,8 @@ int resolve_gitlink_ref(const char *submodule, const char *refname, if (!refs) return -1; - if (!refs_resolve_ref_unsafe(refs, refname, 0, sha1, &flags) || - is_null_sha1(sha1)) + if (!refs_resolve_ref_unsafe(refs, refname, 0, oid->hash, &flags) || + is_null_oid(oid)) return -1; return 0; } diff --git a/refs.h b/refs.h index 50f6f0d..ee07a45 100644 --- a/refs.h +++ b/refs.h @@ -130,7 +130,7 @@ int peel_ref(const char *refname, struct object_id *oid); * otherwise, return a non-zero value. */ int resolve_gitlink_ref(const char *submodule, const char *refname, - unsigned char *sha1); + struct object_id *oid); /* * Return true iff abbrev_name is a possible abbreviation for diff --git a/sha1_file.c b/sha1_file.c index cd910b2..0f44351 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1841,7 +1841,7 @@ int index_path(struct object_id *oid, const char *path, struct stat *st, unsigne strbuf_release(&sb); break; case S_IFDIR: - return resolve_gitlink_ref(path, "HEAD", oid->hash); + return resolve_gitlink_ref(path, "HEAD", oid); default: return error("%s: unsupported file type", path); } diff --git a/unpack-trees.c b/unpack-trees.c index 0dc76ed..25740cb 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -1542,7 +1542,7 @@ static int verify_clean_subdirectory(const struct cache_entry *ce, if (S_ISGITLINK(ce->ce_mode)) { struct object_id oid; - int sub_head = resolve_gitlink_ref(ce->name, "HEAD", oid.hash); + int sub_head = resolve_gitlink_ref(ce->name, "HEAD", &oid); /* * If we are not going to update the submodule, then * we don't care. -- cgit v0.10.2-6-g49f6