mirror of
https://github.com/git/git.git
synced 2024-11-18 02:23:52 +01:00
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>
This commit is contained in:
parent
1053fe829c
commit
a98e6101f0
@ -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. */
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
4
dir.c
4
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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
6
refs.c
6
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;
|
||||
}
|
||||
|
2
refs.h
2
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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user