提交 0f2dc722 编写于 作者: B brian m. carlson 提交者: Junio C Hamano

refs: convert resolve_refdup and refs_resolve_refdup to struct object_id

All of the callers already pass the hash member of struct object_id, so
update them to pass a pointer to the struct directly,

This transformation was done with an update to declaration and
definition and the following semantic patch:

@@
expression E1, E2, E3, E4;
@@
- resolve_refdup(E1, E2, E3.hash, E4)
+ resolve_refdup(E1, E2, &E3, E4)

@@
expression E1, E2, E3, E4;
@@
- resolve_refdup(E1, E2, E3->hash, E4)
+ resolve_refdup(E1, E2, E3, E4)
Signed-off-by: Nbrian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 6ccac9ee
...@@ -2135,7 +2135,7 @@ static void am_abort(struct am_state *state) ...@@ -2135,7 +2135,7 @@ static void am_abort(struct am_state *state)
am_rerere_clear(); am_rerere_clear();
curr_branch = resolve_refdup("HEAD", 0, curr_head.hash, NULL); curr_branch = resolve_refdup("HEAD", 0, &curr_head, NULL);
has_curr_head = curr_branch && !is_null_oid(&curr_head); has_curr_head = curr_branch && !is_null_oid(&curr_head);
if (!has_curr_head) if (!has_curr_head)
hashcpy(curr_head.hash, EMPTY_TREE_SHA1_BIN); hashcpy(curr_head.hash, EMPTY_TREE_SHA1_BIN);
......
...@@ -125,7 +125,7 @@ static int branch_merged(int kind, const char *name, ...@@ -125,7 +125,7 @@ static int branch_merged(int kind, const char *name,
if (upstream && if (upstream &&
(reference_name = reference_name_to_free = (reference_name = reference_name_to_free =
resolve_refdup(upstream, RESOLVE_REF_READING, resolve_refdup(upstream, RESOLVE_REF_READING,
oid.hash, NULL)) != NULL) &oid, NULL)) != NULL)
reference_rev = lookup_commit_reference(&oid); reference_rev = lookup_commit_reference(&oid);
} }
if (!reference_rev) if (!reference_rev)
...@@ -241,7 +241,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds, ...@@ -241,7 +241,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
RESOLVE_REF_READING RESOLVE_REF_READING
| RESOLVE_REF_NO_RECURSE | RESOLVE_REF_NO_RECURSE
| RESOLVE_REF_ALLOW_BAD_NAME, | RESOLVE_REF_ALLOW_BAD_NAME,
oid.hash, &flags); &oid, &flags);
if (!target) { if (!target) {
error(remote_branch error(remote_branch
? _("remote-tracking branch '%s' not found.") ? _("remote-tracking branch '%s' not found.")
...@@ -636,7 +636,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix) ...@@ -636,7 +636,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
track = git_branch_track; track = git_branch_track;
head = resolve_refdup("HEAD", 0, head_oid.hash, NULL); head = resolve_refdup("HEAD", 0, &head_oid, NULL);
if (!head) if (!head)
die(_("Failed to resolve HEAD as a valid ref.")); die(_("Failed to resolve HEAD as a valid ref."));
if (!strcmp(head, "HEAD")) if (!strcmp(head, "HEAD"))
......
...@@ -827,7 +827,7 @@ static int switch_branches(const struct checkout_opts *opts, ...@@ -827,7 +827,7 @@ static int switch_branches(const struct checkout_opts *opts,
struct object_id rev; struct object_id rev;
int flag, writeout_error = 0; int flag, writeout_error = 0;
memset(&old, 0, sizeof(old)); memset(&old, 0, sizeof(old));
old.path = path_to_free = resolve_refdup("HEAD", 0, rev.hash, &flag); old.path = path_to_free = resolve_refdup("HEAD", 0, &rev, &flag);
if (old.path) if (old.path)
old.commit = lookup_commit_reference_gently(&rev, 1); old.commit = lookup_commit_reference_gently(&rev, 1);
if (!(flag & REF_ISSYMREF)) if (!(flag & REF_ISSYMREF))
......
...@@ -715,7 +715,7 @@ static int checkout(int submodule_progress) ...@@ -715,7 +715,7 @@ static int checkout(int submodule_progress)
if (option_no_checkout) if (option_no_checkout)
return 0; return 0;
head = resolve_refdup("HEAD", RESOLVE_REF_READING, oid.hash, NULL); head = resolve_refdup("HEAD", RESOLVE_REF_READING, &oid, NULL);
if (!head) { if (!head) {
warning(_("remote HEAD refers to nonexistent ref, " warning(_("remote HEAD refers to nonexistent ref, "
"unable to checkout.\n")); "unable to checkout.\n"));
......
...@@ -603,7 +603,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out, ...@@ -603,7 +603,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
/* get current branch */ /* get current branch */
current_branch = current_branch_to_free = current_branch = current_branch_to_free =
resolve_refdup("HEAD", RESOLVE_REF_READING, head_oid.hash, NULL); resolve_refdup("HEAD", RESOLVE_REF_READING, &head_oid, NULL);
if (!current_branch) if (!current_branch)
die("No current branch"); die("No current branch");
if (starts_with(current_branch, "refs/heads/")) if (starts_with(current_branch, "refs/heads/"))
......
...@@ -1142,7 +1142,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) ...@@ -1142,7 +1142,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
* Check if we are _not_ on a detached HEAD, i.e. if there is a * Check if we are _not_ on a detached HEAD, i.e. if there is a
* current branch. * current branch.
*/ */
branch = branch_to_free = resolve_refdup("HEAD", 0, head_oid.hash, NULL); branch = branch_to_free = resolve_refdup("HEAD", 0, &head_oid, NULL);
if (branch) if (branch)
skip_prefix(branch, "refs/heads/", &branch); skip_prefix(branch, "refs/heads/", &branch);
if (!branch || is_null_oid(&head_oid)) if (!branch || is_null_oid(&head_oid))
......
...@@ -724,7 +724,7 @@ static int merge_commit(struct notes_merge_options *o) ...@@ -724,7 +724,7 @@ static int merge_commit(struct notes_merge_options *o)
init_notes(t, "NOTES_MERGE_PARTIAL", combine_notes_overwrite, 0); init_notes(t, "NOTES_MERGE_PARTIAL", combine_notes_overwrite, 0);
o->local_ref = local_ref_to_free = o->local_ref = local_ref_to_free =
resolve_refdup("NOTES_MERGE_REF", 0, oid.hash, NULL); resolve_refdup("NOTES_MERGE_REF", 0, &oid, NULL);
if (!o->local_ref) if (!o->local_ref)
die(_("failed to resolve NOTES_MERGE_REF")); die(_("failed to resolve NOTES_MERGE_REF"));
......
...@@ -705,8 +705,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) ...@@ -705,8 +705,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
static const char *fake_av[2]; static const char *fake_av[2];
fake_av[0] = resolve_refdup("HEAD", fake_av[0] = resolve_refdup("HEAD",
RESOLVE_REF_READING, RESOLVE_REF_READING, &oid,
oid.hash, NULL); NULL);
fake_av[1] = NULL; fake_av[1] = NULL;
av = fake_av; av = fake_av;
ac = 1; ac = 1;
...@@ -775,7 +775,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) ...@@ -775,7 +775,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
} }
head = resolve_refdup("HEAD", RESOLVE_REF_READING, head = resolve_refdup("HEAD", RESOLVE_REF_READING,
head_oid.hash, NULL); &head_oid, NULL);
if (with_current_branch && head) { if (with_current_branch && head) {
int has_head = 0; int has_head = 0;
......
...@@ -1144,7 +1144,7 @@ static int push_check(int argc, const char **argv, const char *prefix) ...@@ -1144,7 +1144,7 @@ static int push_check(int argc, const char **argv, const char *prefix)
argv++; argv++;
argc--; argc--;
/* Get the submodule's head ref and determine if it is detached */ /* Get the submodule's head ref and determine if it is detached */
head = resolve_refdup("HEAD", 0, head_oid.hash, NULL); head = resolve_refdup("HEAD", 0, &head_oid, NULL);
if (!head) if (!head)
die(_("Failed to resolve HEAD as a valid ref.")); die(_("Failed to resolve HEAD as a valid ref."));
if (!strcmp(head, "HEAD")) if (!strcmp(head, "HEAD"))
......
...@@ -194,21 +194,21 @@ int ref_resolves_to_object(const char *refname, ...@@ -194,21 +194,21 @@ int ref_resolves_to_object(const char *refname,
char *refs_resolve_refdup(struct ref_store *refs, char *refs_resolve_refdup(struct ref_store *refs,
const char *refname, int resolve_flags, const char *refname, int resolve_flags,
unsigned char *sha1, int *flags) struct object_id *oid, int *flags)
{ {
const char *result; const char *result;
result = refs_resolve_ref_unsafe(refs, refname, resolve_flags, result = refs_resolve_ref_unsafe(refs, refname, resolve_flags,
sha1, flags); oid->hash, flags);
return xstrdup_or_null(result); return xstrdup_or_null(result);
} }
char *resolve_refdup(const char *refname, int resolve_flags, char *resolve_refdup(const char *refname, int resolve_flags,
unsigned char *sha1, int *flags) struct object_id *oid, int *flags)
{ {
return refs_resolve_refdup(get_main_ref_store(), return refs_resolve_refdup(get_main_ref_store(),
refname, resolve_flags, refname, resolve_flags,
sha1, flags); oid, flags);
} }
/* The argument to filter_refs */ /* The argument to filter_refs */
......
...@@ -69,9 +69,9 @@ const char *resolve_ref_unsafe(const char *refname, int resolve_flags, ...@@ -69,9 +69,9 @@ const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
char *refs_resolve_refdup(struct ref_store *refs, char *refs_resolve_refdup(struct ref_store *refs,
const char *refname, int resolve_flags, const char *refname, int resolve_flags,
unsigned char *sha1, int *flags); struct object_id *oid, int *flags);
char *resolve_refdup(const char *refname, int resolve_flags, char *resolve_refdup(const char *refname, int resolve_flags,
unsigned char *sha1, int *flags); struct object_id *oid, int *flags);
int refs_read_ref_full(struct ref_store *refs, const char *refname, int refs_read_ref_full(struct ref_store *refs, const char *refname,
int resolve_flags, unsigned char *sha1, int *flags); int resolve_flags, unsigned char *sha1, int *flags);
......
...@@ -1016,7 +1016,7 @@ int push_unpushed_submodules(struct oid_array *commits, ...@@ -1016,7 +1016,7 @@ int push_unpushed_submodules(struct oid_array *commits,
char *head; char *head;
struct object_id head_oid; struct object_id head_oid;
head = resolve_refdup("HEAD", 0, head_oid.hash, NULL); head = resolve_refdup("HEAD", 0, &head_oid, NULL);
if (!head) if (!head)
die(_("Failed to resolve HEAD as a valid ref.")); die(_("Failed to resolve HEAD as a valid ref."));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册