aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2017-10-15 22:07:07 +0000
committerJunio C Hamano <gitster@pobox.com>2017-10-16 11:05:51 +0900
commita98e6101f01b6991e780fc0b75f2937615fa84a9 (patch)
tree50035adb93a84ce2468f44027e1620c5253a76ec
parent1053fe829c037c5a725786bac35d05a113c91f55 (diff)
downloadgit-a98e6101f01b6991e780fc0b75f2937615fa84a9.tar.gz
git-a98e6101f01b6991e780fc0b75f2937615fa84a9.tar.xz
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 <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/update-index.c4
-rw-r--r--combine-diff.c2
-rw-r--r--diff-lib.c2
-rw-r--r--dir.c4
-rw-r--r--read-cache.c2
-rw-r--r--refs.c6
-rw-r--r--refs.h2
-rw-r--r--sha1_file.c2
-rw-r--r--unpack-trees.c2
9 files changed, 13 insertions, 13 deletions
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 24f4b2895..fefbe6016 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 9e163d5ad..82f607097 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 af4f1b786..d2ea02f4d 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 a4198ba7f..f09a31e10 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 131485b3a..7766196af 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 37485283c..90219d6e1 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 50f6f0dbd..ee07a457a 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 cd910b210..0f4435192 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 0dc76eddf..25740cb59 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.