Skip to content

Commit 1053fe8

Browse files
bk2204gitster
authored andcommitted
Convert remaining callers of resolve_gitlink_ref to object_id
Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bcd2986 commit 1053fe8

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

diff-lib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static int check_removed(const struct cache_entry *ce, struct stat *st)
3636
if (has_symlink_leading_path(ce->name, ce_namelen(ce)))
3737
return 1;
3838
if (S_ISDIR(st->st_mode)) {
39-
unsigned char sub[20];
39+
struct object_id sub;
4040

4141
/*
4242
* If ce is already a gitlink, we can have a plain
@@ -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))
53+
resolve_gitlink_ref(ce->name, "HEAD", sub.hash))
5454
return 1;
5555
}
5656
return 0;

dir.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,8 +1390,8 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
13901390
if (dir->flags & DIR_SHOW_OTHER_DIRECTORIES)
13911391
break;
13921392
if (!(dir->flags & DIR_NO_GITLINKS)) {
1393-
unsigned char sha1[20];
1394-
if (resolve_gitlink_ref(dirname, "HEAD", sha1) == 0)
1393+
struct object_id oid;
1394+
if (resolve_gitlink_ref(dirname, "HEAD", oid.hash) == 0)
13951395
return path_untracked;
13961396
}
13971397
return path_recurse;
@@ -2279,10 +2279,10 @@ static int remove_dir_recurse(struct strbuf *path, int flag, int *kept_up)
22792279
int ret = 0, original_len = path->len, len, kept_down = 0;
22802280
int only_empty = (flag & REMOVE_DIR_EMPTY_ONLY);
22812281
int keep_toplevel = (flag & REMOVE_DIR_KEEP_TOPLEVEL);
2282-
unsigned char submodule_head[20];
2282+
struct object_id submodule_head;
22832283

22842284
if ((flag & REMOVE_DIR_KEEP_NESTED_GIT) &&
2285-
!resolve_gitlink_ref(path->buf, "HEAD", submodule_head)) {
2285+
!resolve_gitlink_ref(path->buf, "HEAD", submodule_head.hash)) {
22862286
/* Do not descend and nuke a nested git work tree. */
22872287
if (kept_up)
22882288
*kept_up = 1;

read-cache.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ static int ce_compare_link(const struct cache_entry *ce, size_t expected_size)
191191

192192
static int ce_compare_gitlink(const struct cache_entry *ce)
193193
{
194-
unsigned char sha1[20];
194+
struct object_id oid;
195195

196196
/*
197197
* We don't actually require that the .git directory
@@ -201,9 +201,9 @@ 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", sha1) < 0)
204+
if (resolve_gitlink_ref(ce->name, "HEAD", oid.hash) < 0)
205205
return 0;
206-
return hashcmp(sha1, ce->oid.hash);
206+
return oidcmp(&oid, &ce->oid);
207207
}
208208

209209
static int ce_modified_check_fs(const struct cache_entry *ce, struct stat *st)

unpack-trees.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,15 +1541,15 @@ static int verify_clean_subdirectory(const struct cache_entry *ce,
15411541
int cnt = 0;
15421542

15431543
if (S_ISGITLINK(ce->ce_mode)) {
1544-
unsigned char sha1[20];
1545-
int sub_head = resolve_gitlink_ref(ce->name, "HEAD", sha1);
1544+
struct object_id oid;
1545+
int sub_head = resolve_gitlink_ref(ce->name, "HEAD", oid.hash);
15461546
/*
15471547
* If we are not going to update the submodule, then
15481548
* we don't care.
15491549
*/
1550-
if (!sub_head && !hashcmp(sha1, ce->oid.hash))
1550+
if (!sub_head && !oidcmp(&oid, &ce->oid))
15511551
return 0;
1552-
return verify_clean_submodule(sub_head ? NULL : sha1_to_hex(sha1),
1552+
return verify_clean_submodule(sub_head ? NULL : oid_to_hex(&oid),
15531553
ce, error_type, o);
15541554
}
15551555

0 commit comments

Comments
 (0)