]> granicus.if.org Git - git/commitdiff
refs: convert resolve_gitlink_ref to struct object_id
authorbrian m. carlson <sandals@crustytoothpaste.net>
Sun, 15 Oct 2017 22:07:07 +0000 (22:07 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 16 Oct 2017 02:05:51 +0000 (11:05 +0900)
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 <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/update-index.c
combine-diff.c
diff-lib.c
dir.c
read-cache.c
refs.c
refs.h
sha1_file.c
unpack-trees.c

index 24f4b28951e4ec4b78406e09efe26c2706016aa0..fefbe601673398e6f63e20f63e669a5ef548c776 100644 (file)
@@ -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. */
index 9e163d5adabd93fd48a6b563c5f31c32740e01c7..82f6070977cf8316fd630cc86fbf9d393d03ba3a 100644 (file)
@@ -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
index af4f1b7865d9587e304ba099b7e843b1c5a29a7c..d2ea02f4d7c9074aff577d9529640315db9c5af7 100644 (file)
@@ -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 a4198ba7fd7f334b947dc7ba7d14b588df1f32e2..f09a31e102232b2c138358585b00635a40227c6e 100644 (file)
--- 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;
index 131485b3a6f029253f4a79fb79ef08aa6bc01cc7..7766196aff5afc639b6cc8ccd76a65af9de96500 100644 (file)
@@ -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 37485283c0f7133a92107629db169d2a6f12b169..90219d6e132eb134db9918d06d388ede0513ef80 100644 (file)
--- 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 50f6f0dbd722f254f161529ad19325883d2df232..ee07a457af4aed413ce2a96db50f3d5ea7ea7b1e 100644 (file)
--- 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
index cd910b2103caf335e7b98cd543a00aa4cdb88040..0f4435192fe93708aa466bdae2ac45deaace7db2 100644 (file)
@@ -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);
        }
index 0dc76eddfe760249059f8caa667c990c7a0a3bb8..25740cb5937557f4d017ce89be042379bfc7a219 100644 (file)
@@ -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.