Skip to content

Commit a98e610

Browse files
bk2204gitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1053fe8 commit a98e610

File tree

9 files changed

+13
-13
lines changed

9 files changed

+13
-13
lines changed

builtin/update-index.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ static int process_directory(const char *path, int len, struct stat *st)
328328
if (S_ISGITLINK(ce->ce_mode)) {
329329

330330
/* 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)
332332
return 0;
333333

334334
return add_one_path(ce, path, len, st);
@@ -354,7 +354,7 @@ static int process_directory(const char *path, int len, struct stat *st)
354354
}
355355

356356
/* 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))
358358
return add_one_path(NULL, path, len, st);
359359

360360
/* Error out. */

combine-diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
10141014
elem->mode = canon_mode(st.st_mode);
10151015
} else if (S_ISDIR(st.st_mode)) {
10161016
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)
10181018
result = grab_blob(&elem->oid, elem->mode,
10191019
&result_size, NULL, NULL);
10201020
else

diff-lib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static int check_removed(const struct cache_entry *ce, struct stat *st)
5050
* a directory --- the blob was removed!
5151
*/
5252
if (!S_ISGITLINK(ce->ce_mode) &&
53-
resolve_gitlink_ref(ce->name, "HEAD", sub.hash))
53+
resolve_gitlink_ref(ce->name, "HEAD", &sub))
5454
return 1;
5555
}
5656
return 0;

dir.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,7 +1391,7 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
13911391
break;
13921392
if (!(dir->flags & DIR_NO_GITLINKS)) {
13931393
struct object_id oid;
1394-
if (resolve_gitlink_ref(dirname, "HEAD", oid.hash) == 0)
1394+
if (resolve_gitlink_ref(dirname, "HEAD", &oid) == 0)
13951395
return path_untracked;
13961396
}
13971397
return path_recurse;
@@ -2282,7 +2282,7 @@ static int remove_dir_recurse(struct strbuf *path, int flag, int *kept_up)
22822282
struct object_id submodule_head;
22832283

22842284
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)) {
22862286
/* Do not descend and nuke a nested git work tree. */
22872287
if (kept_up)
22882288
*kept_up = 1;

read-cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ static int ce_compare_gitlink(const struct cache_entry *ce)
201201
*
202202
* If so, we consider it always to match.
203203
*/
204-
if (resolve_gitlink_ref(ce->name, "HEAD", oid.hash) < 0)
204+
if (resolve_gitlink_ref(ce->name, "HEAD", &oid) < 0)
205205
return 0;
206206
return oidcmp(&oid, &ce->oid);
207207
}

refs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,7 +1498,7 @@ const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
14981498
}
14991499

15001500
int resolve_gitlink_ref(const char *submodule, const char *refname,
1501-
unsigned char *sha1)
1501+
struct object_id *oid)
15021502
{
15031503
struct ref_store *refs;
15041504
int flags;
@@ -1508,8 +1508,8 @@ int resolve_gitlink_ref(const char *submodule, const char *refname,
15081508
if (!refs)
15091509
return -1;
15101510

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))
15131513
return -1;
15141514
return 0;
15151515
}

refs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ int peel_ref(const char *refname, struct object_id *oid);
130130
* otherwise, return a non-zero value.
131131
*/
132132
int resolve_gitlink_ref(const char *submodule, const char *refname,
133-
unsigned char *sha1);
133+
struct object_id *oid);
134134

135135
/*
136136
* Return true iff abbrev_name is a possible abbreviation for

sha1_file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1841,7 +1841,7 @@ int index_path(struct object_id *oid, const char *path, struct stat *st, unsigne
18411841
strbuf_release(&sb);
18421842
break;
18431843
case S_IFDIR:
1844-
return resolve_gitlink_ref(path, "HEAD", oid->hash);
1844+
return resolve_gitlink_ref(path, "HEAD", oid);
18451845
default:
18461846
return error("%s: unsupported file type", path);
18471847
}

unpack-trees.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1542,7 +1542,7 @@ static int verify_clean_subdirectory(const struct cache_entry *ce,
15421542

15431543
if (S_ISGITLINK(ce->ce_mode)) {
15441544
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);
15461546
/*
15471547
* If we are not going to update the submodule, then
15481548
* we don't care.

0 commit comments

Comments
 (0)