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: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Oct 15, 2017 at 22:06 UTC
0f2dc722dd01097d1e1c1dac43b2f57924594457
12 files changed
+20
-20
builtin/am.c
+1
-1
@@ -2135,7 +2135,7 @@ static void am_abort(struct am_state *state)
2135
2136
am_rerere_clear();
2137
2138
- curr_branch = resolve_refdup("HEAD", 0, curr_head.hash, NULL);
2138
+ curr_branch = resolve_refdup("HEAD", 0, &curr_head, NULL);
2139
has_curr_head = curr_branch && !is_null_oid(&curr_head);
2140
if (!has_curr_head)
2141
hashcpy(curr_head.hash, EMPTY_TREE_SHA1_BIN);
builtin/branch.c
+3
-3
@@ -125,7 +125,7 @@ static int branch_merged(int kind, const char *name,
125
if (upstream &&
126
(reference_name = reference_name_to_free =
127
resolve_refdup(upstream, RESOLVE_REF_READING,
128
- oid.hash, NULL)) != NULL)
128
+ &oid, NULL)) != NULL)
129
reference_rev = lookup_commit_reference(&oid);
130
}
131
if (!reference_rev)
@@ -241,7 +241,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
241
RESOLVE_REF_READING
242
| RESOLVE_REF_NO_RECURSE
243
| RESOLVE_REF_ALLOW_BAD_NAME,
244
- oid.hash, &flags);
244
+ &oid, &flags);
245
if (!target) {
246
error(remote_branch
247
? _("remote-tracking branch '%s' not found.")
@@ -636,7 +636,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
636
637
track = git_branch_track;
638
639
- head = resolve_refdup("HEAD", 0, head_oid.hash, NULL);
639
+ head = resolve_refdup("HEAD", 0, &head_oid, NULL);
640
if (!head)
641
die(_("Failed to resolve HEAD as a valid ref."));
642
if (!strcmp(head, "HEAD"))
builtin/checkout.c
+1
-1
@@ -827,7 +827,7 @@ static int switch_branches(const struct checkout_opts *opts,
827
struct object_id rev;
828
int flag, writeout_error = 0;
829
memset(&old, 0, sizeof(old));
830
- old.path = path_to_free = resolve_refdup("HEAD", 0, rev.hash, &flag);
830
+ old.path = path_to_free = resolve_refdup("HEAD", 0, &rev, &flag);
831
if (old.path)
832
old.commit = lookup_commit_reference_gently(&rev, 1);
833
if (!(flag & REF_ISSYMREF))
builtin/clone.c
+1
-1
@@ -715,7 +715,7 @@ static int checkout(int submodule_progress)
715
if (option_no_checkout)
716
return 0;
717
718
- head = resolve_refdup("HEAD", RESOLVE_REF_READING, oid.hash, NULL);
718
+ head = resolve_refdup("HEAD", RESOLVE_REF_READING, &oid, NULL);
719
if (!head) {
720
warning(_("remote HEAD refers to nonexistent ref, "
721
"unable to checkout.\n"));
builtin/fmt-merge-msg.c
+1
-1
@@ -603,7 +603,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
603
604
/* get current branch */
605
current_branch = current_branch_to_free =
606
- resolve_refdup("HEAD", RESOLVE_REF_READING, head_oid.hash, NULL);
606
+ resolve_refdup("HEAD", RESOLVE_REF_READING, &head_oid, NULL);
607
if (!current_branch)
608
die("No current branch");
609
if (starts_with(current_branch, "refs/heads/"))
builtin/merge.c
+1
-1
@@ -1142,7 +1142,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1142
* Check if we are _not_ on a detached HEAD, i.e. if there is a
1143
* current branch.
1144
*/
1145
- branch = branch_to_free = resolve_refdup("HEAD", 0, head_oid.hash, NULL);
1145
+ branch = branch_to_free = resolve_refdup("HEAD", 0, &head_oid, NULL);
1146
if (branch)
1147
skip_prefix(branch, "refs/heads/", &branch);
1148
if (!branch || is_null_oid(&head_oid))
builtin/notes.c
+1
-1
@@ -724,7 +724,7 @@ static int merge_commit(struct notes_merge_options *o)
724
init_notes(t, "NOTES_MERGE_PARTIAL", combine_notes_overwrite, 0);
725
726
o->local_ref = local_ref_to_free =
727
- resolve_refdup("NOTES_MERGE_REF", 0, oid.hash, NULL);
727
+ resolve_refdup("NOTES_MERGE_REF", 0, &oid, NULL);
728
if (!o->local_ref)
729
die(_("failed to resolve NOTES_MERGE_REF"));
730
builtin/show-branch.c
+3
-3
@@ -705,8 +705,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
705
static const char *fake_av[2];
706
707
fake_av[0] = resolve_refdup("HEAD",
708
- RESOLVE_REF_READING,
709
- oid.hash, NULL);
708
+ RESOLVE_REF_READING, &oid,
709
+ NULL);
710
fake_av[1] = NULL;
711
av = fake_av;
712
ac = 1;
@@ -775,7 +775,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
775
}
776
777
head = resolve_refdup("HEAD", RESOLVE_REF_READING,
778
- head_oid.hash, NULL);
778
+ &head_oid, NULL);
779
780
if (with_current_branch && head) {
781
int has_head = 0;
builtin/submodule--helper.c
+1
-1
@@ -1144,7 +1144,7 @@ static int push_check(int argc, const char **argv, const char *prefix)
1144
argv++;
1145
argc--;
1146
/* Get the submodule's head ref and determine if it is detached */
1147
- head = resolve_refdup("HEAD", 0, head_oid.hash, NULL);
1147
+ head = resolve_refdup("HEAD", 0, &head_oid, NULL);
1148
if (!head)
1149
die(_("Failed to resolve HEAD as a valid ref."));
1150
if (!strcmp(head, "HEAD"))
refs.c
+4
-4
@@ -194,21 +194,21 @@ int ref_resolves_to_object(const char *refname,
194
195
char *refs_resolve_refdup(struct ref_store *refs,
196
const char *refname, int resolve_flags,
197
- unsigned char *sha1, int *flags)
197
+ struct object_id *oid, int *flags)
198
{
199
const char *result;
200
201
result = refs_resolve_ref_unsafe(refs, refname, resolve_flags,
202
- sha1, flags);
202
+ oid->hash, flags);
203
return xstrdup_or_null(result);
204
}
205
206
char *resolve_refdup(const char *refname, int resolve_flags,
207
- unsigned char *sha1, int *flags)
207
+ struct object_id *oid, int *flags)
208
{
209
return refs_resolve_refdup(get_main_ref_store(),
210
refname, resolve_flags,
211
- sha1, flags);
211
+ oid, flags);
212
}
213
214
/* The argument to filter_refs */
refs.h
+2
-2
@@ -69,9 +69,9 @@ const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
69
70
char *refs_resolve_refdup(struct ref_store *refs,
71
const char *refname, int resolve_flags,
72
- unsigned char *sha1, int *flags);
72
+ struct object_id *oid, int *flags);
73
char *resolve_refdup(const char *refname, int resolve_flags,
74
- unsigned char *sha1, int *flags);
74
+ struct object_id *oid, int *flags);
75
76
int refs_read_ref_full(struct ref_store *refs, const char *refname,
77
int resolve_flags, unsigned char *sha1, int *flags);
submodule.c
+1
-1
@@ -1016,7 +1016,7 @@ int push_unpushed_submodules(struct oid_array *commits,
1016
char *head;
1017
struct object_id head_oid;
1018
1019
- head = resolve_refdup("HEAD", 0, head_oid.hash, NULL);
1019
+ head = resolve_refdup("HEAD", 0, &head_oid, NULL);
1020
if (!head)
1021
die(_("Failed to resolve HEAD as a valid ref."));
1022