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>
brian m. carlson committed
Oct 15, 2017 at 22:07 UTC
a98e6101f01b6991e780fc0b75f2937615fa84a9
9 files changed
+13
-13
builtin/update-index.c
+2
-2
@@ -328,7 +328,7 @@ static int process_directory(const char *path, int len, struct stat *st)
328
if (S_ISGITLINK(ce->ce_mode)) {
329
330
/* Do nothing to the index if there is no HEAD! */
331
- if (resolve_gitlink_ref(path, "HEAD", oid.hash) < 0)
331
+ if (resolve_gitlink_ref(path, "HEAD", &oid) < 0)
332
return 0;
333
334
return add_one_path(ce, path, len, st);
@@ -354,7 +354,7 @@ static int process_directory(const char *path, int len, struct stat *st)
354
}
355
356
/* No match - should we add it as a gitlink? */
357
- if (!resolve_gitlink_ref(path, "HEAD", oid.hash))
357
+ if (!resolve_gitlink_ref(path, "HEAD", &oid))
358
return add_one_path(NULL, path, len, st);
359
360
/* Error out. */
combine-diff.c
+1
-1
@@ -1014,7 +1014,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
1014
elem->mode = canon_mode(st.st_mode);
1015
} else if (S_ISDIR(st.st_mode)) {
1016
struct object_id oid;
1017
- if (resolve_gitlink_ref(elem->path, "HEAD", oid.hash) < 0)
1017
+ if (resolve_gitlink_ref(elem->path, "HEAD", &oid) < 0)
1018
result = grab_blob(&elem->oid, elem->mode,
1019
&result_size, NULL, NULL);
1020
else
diff-lib.c
+1
-1
@@ -50,7 +50,7 @@ static int check_removed(const struct cache_entry *ce, struct stat *st)
50
* a directory --- the blob was removed!
51
*/
52
if (!S_ISGITLINK(ce->ce_mode) &&
53
- resolve_gitlink_ref(ce->name, "HEAD", sub.hash))
53
+ resolve_gitlink_ref(ce->name, "HEAD", &sub))
54
return 1;
55
}
56
return 0;
dir.c
+2
-2
@@ -1391,7 +1391,7 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
1391
break;
1392
if (!(dir->flags & DIR_NO_GITLINKS)) {
1393
struct object_id oid;
1394
- if (resolve_gitlink_ref(dirname, "HEAD", oid.hash) == 0)
1394
+ if (resolve_gitlink_ref(dirname, "HEAD", &oid) == 0)
1395
return path_untracked;
1396
}
1397
return path_recurse;
@@ -2282,7 +2282,7 @@ static int remove_dir_recurse(struct strbuf *path, int flag, int *kept_up)
2282
struct object_id submodule_head;
2283
2284
if ((flag & REMOVE_DIR_KEEP_NESTED_GIT) &&
2285
- !resolve_gitlink_ref(path->buf, "HEAD", submodule_head.hash)) {
2285
+ !resolve_gitlink_ref(path->buf, "HEAD", &submodule_head)) {
2286
/* Do not descend and nuke a nested git work tree. */
2287
if (kept_up)
2288
*kept_up = 1;
read-cache.c
+1
-1
@@ -201,7 +201,7 @@ static int ce_compare_gitlink(const struct cache_entry *ce)
201
*
202
* If so, we consider it always to match.
203
*/
204
- if (resolve_gitlink_ref(ce->name, "HEAD", oid.hash) < 0)
204
+ if (resolve_gitlink_ref(ce->name, "HEAD", &oid) < 0)
205
return 0;
206
return oidcmp(&oid, &ce->oid);
207
}
refs.c
+3
-3
@@ -1498,7 +1498,7 @@ const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
1498
}
1499
1500
int resolve_gitlink_ref(const char *submodule, const char *refname,
1501
- unsigned char *sha1)
1501
+ struct object_id *oid)
1502
{
1503
struct ref_store *refs;
1504
int flags;
@@ -1508,8 +1508,8 @@ int resolve_gitlink_ref(const char *submodule, const char *refname,
1508
if (!refs)
1509
return -1;
1510
1511
- if (!refs_resolve_ref_unsafe(refs, refname, 0, sha1, &flags) ||
1512
- is_null_sha1(sha1))
1511
+ if (!refs_resolve_ref_unsafe(refs, refname, 0, oid->hash, &flags) ||
1512
+ is_null_oid(oid))
1513
return -1;
1514
return 0;
1515
}
refs.h
+1
-1
@@ -130,7 +130,7 @@ int peel_ref(const char *refname, struct object_id *oid);
130
* otherwise, return a non-zero value.
131
*/
132
int resolve_gitlink_ref(const char *submodule, const char *refname,
133
- unsigned char *sha1);
133
+ struct object_id *oid);
134
135
/*
136
* Return true iff abbrev_name is a possible abbreviation for
sha1_file.c
+1
-1
@@ -1841,7 +1841,7 @@ int index_path(struct object_id *oid, const char *path, struct stat *st, unsigne
1841
strbuf_release(&sb);
1842
break;
1843
case S_IFDIR:
1844
- return resolve_gitlink_ref(path, "HEAD", oid->hash);
1844
+ return resolve_gitlink_ref(path, "HEAD", oid);
1845
default:
1846
return error("%s: unsupported file type", path);
1847
}
unpack-trees.c
+1
-1
@@ -1542,7 +1542,7 @@ static int verify_clean_subdirectory(const struct cache_entry *ce,
1542
1543
if (S_ISGITLINK(ce->ce_mode)) {
1544
struct object_id oid;
1545
- int sub_head = resolve_gitlink_ref(ce->name, "HEAD", oid.hash);
1545
+ int sub_head = resolve_gitlink_ref(ce->name, "HEAD", &oid);
1546
/*
1547
* If we are not going to update the submodule, then
1548
* we don't care.