Convert remaining callers of resolve_refdup to object_id
There are a few leaf functions in various files that call resolve_refdup. Convert these functions to use struct object_id internally to prepare for transitioning resolve_refdup itself. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Feb 21, 2017 at 23:47 UTC
2928325fc0b676876fcda5ffcbc461695aaedbb8
6 files changed
+23
-23
builtin/notes.c
+9
-9
@@ -693,7 +693,7 @@ static int merge_abort(struct notes_merge_options *o)
693
static int merge_commit(struct notes_merge_options *o)
694
{
695
struct strbuf msg = STRBUF_INIT;
696
- unsigned char sha1[20], parent_sha1[20];
696
+ struct object_id oid, parent_oid;
697
struct notes_tree *t;
698
struct commit *partial;
699
struct pretty_print_context pretty_ctx;
@@ -705,27 +705,27 @@ static int merge_commit(struct notes_merge_options *o)
705
* and target notes ref from .git/NOTES_MERGE_REF.
706
*/
707
708
- if (get_sha1("NOTES_MERGE_PARTIAL", sha1))
708
+ if (get_oid("NOTES_MERGE_PARTIAL", &oid))
709
die(_("failed to read ref NOTES_MERGE_PARTIAL"));
710
- else if (!(partial = lookup_commit_reference(sha1)))
710
+ else if (!(partial = lookup_commit_reference(oid.hash)))
711
die(_("could not find commit from NOTES_MERGE_PARTIAL."));
712
else if (parse_commit(partial))
713
die(_("could not parse commit from NOTES_MERGE_PARTIAL."));
714
715
if (partial->parents)
716
- hashcpy(parent_sha1, partial->parents->item->object.oid.hash);
716
+ oidcpy(&parent_oid, &partial->parents->item->object.oid);
717
else
718
- hashclr(parent_sha1);
718
+ oidclr(&parent_oid);
719
720
t = xcalloc(1, sizeof(struct notes_tree));
721
init_notes(t, "NOTES_MERGE_PARTIAL", combine_notes_overwrite, 0);
722
723
o->local_ref = local_ref_to_free =
724
- resolve_refdup("NOTES_MERGE_REF", 0, sha1, NULL);
724
+ resolve_refdup("NOTES_MERGE_REF", 0, oid.hash, NULL);
725
if (!o->local_ref)
726
die(_("failed to resolve NOTES_MERGE_REF"));
727
728
- if (notes_merge_commit(o, t, partial, sha1))
728
+ if (notes_merge_commit(o, t, partial, oid.hash))
729
die(_("failed to finalize notes merge"));
730
731
/* Reuse existing commit message in reflog message */
@@ -733,8 +733,8 @@ static int merge_commit(struct notes_merge_options *o)
733
format_commit_message(partial, "%s", &msg, &pretty_ctx);
734
strbuf_trim(&msg);
735
strbuf_insert(&msg, 0, "notes: ", 7);
736
- update_ref(msg.buf, o->local_ref, sha1,
737
- is_null_sha1(parent_sha1) ? NULL : parent_sha1,
736
+ update_ref(msg.buf, o->local_ref, oid.hash,
737
+ is_null_oid(&parent_oid) ? NULL : parent_oid.hash,
738
0, UPDATE_REFS_DIE_ON_ERR);
739
740
free_notes(t);
builtin/receive-pack.c
+2
-2
@@ -1414,7 +1414,7 @@ static void execute_commands(struct command *commands,
1414
{
1415
struct check_connected_options opt = CHECK_CONNECTED_INIT;
1416
struct command *cmd;
1417
- unsigned char sha1[20];
1417
+ struct object_id oid;
1418
struct iterate_data data;
1419
struct async muxer;
1420
int err_fd = 0;
@@ -1471,7 +1471,7 @@ static void execute_commands(struct command *commands,
1471
check_aliased_updates(commands);
1472
1473
free(head_name_to_free);
1474
- head_name = head_name_to_free = resolve_refdup("HEAD", 0, sha1, NULL);
1474
+ head_name = head_name_to_free = resolve_refdup("HEAD", 0, oid.hash, NULL);
1475
1476
if (use_atomic)
1477
execute_commands_atomic(commands, si);
ref-filter.c
+2
-2
@@ -961,9 +961,9 @@ static void populate_value(struct ref_array_item *ref)
961
ref->value = xcalloc(used_atom_cnt, sizeof(struct atom_value));
962
963
if (need_symref && (ref->flag & REF_ISSYMREF) && !ref->symref) {
964
- unsigned char unused1[20];
964
+ struct object_id unused1;
965
ref->symref = resolve_refdup(ref->refname, RESOLVE_REF_READING,
966
- unused1, NULL);
966
+ unused1.hash, NULL);
967
if (!ref->symref)
968
ref->symref = "";
969
}
reflog-walk.c
+6
-6
@@ -45,11 +45,11 @@ static struct complete_reflogs *read_complete_reflog(const char *ref)
45
reflogs->ref = xstrdup(ref);
46
for_each_reflog_ent(ref, read_one_reflog, reflogs);
47
if (reflogs->nr == 0) {
48
- unsigned char sha1[20];
48
+ struct object_id oid;
49
const char *name;
50
void *name_to_free;
51
name = name_to_free = resolve_refdup(ref, RESOLVE_REF_READING,
52
- sha1, NULL);
52
+ oid.hash, NULL);
53
if (name) {
54
for_each_reflog_ent(name, read_one_reflog, reflogs);
55
free(name_to_free);
@@ -172,18 +172,18 @@ int add_reflog_for_walk(struct reflog_walk_info *info,
172
reflogs = item->util;
173
else {
174
if (*branch == '\0') {
175
- unsigned char sha1[20];
175
+ struct object_id oid;
176
free(branch);
177
- branch = resolve_refdup("HEAD", 0, sha1, NULL);
177
+ branch = resolve_refdup("HEAD", 0, oid.hash, NULL);
178
if (!branch)
179
die ("No current branch");
180
181
}
182
reflogs = read_complete_reflog(branch);
183
if (!reflogs || reflogs->nr == 0) {
184
- unsigned char sha1[20];
184
+ struct object_id oid;
185
char *b;
186
- if (dwim_log(branch, strlen(branch), sha1, &b) == 1) {
186
+ if (dwim_log(branch, strlen(branch), oid.hash, &b) == 1) {
187
if (reflogs) {
188
free(reflogs->ref);
189
free(reflogs);
transport.c
+2
-2
@@ -467,11 +467,11 @@ void transport_print_push_status(const char *dest, struct ref *refs,
467
{
468
struct ref *ref;
469
int n = 0;
470
- unsigned char head_sha1[20];
470
+ struct object_id head_oid;
471
char *head;
472
int summary_width = transport_summary_width(refs);
473
474
- head = resolve_refdup("HEAD", RESOLVE_REF_READING, head_sha1, NULL);
474
+ head = resolve_refdup("HEAD", RESOLVE_REF_READING, head_oid.hash, NULL);
475
476
if (verbose) {
477
for (ref = refs; ref; ref = ref->next)
wt-status.c
+2
-2
@@ -121,7 +121,7 @@ static void status_printf_more(struct wt_status *s, const char *color,
121
122
void wt_status_prepare(struct wt_status *s)
123
{
124
- unsigned char sha1[20];
124
+ struct object_id oid;
125
126
memset(s, 0, sizeof(*s));
127
memcpy(s->color_palette, default_wt_status_colors,
@@ -129,7 +129,7 @@ void wt_status_prepare(struct wt_status *s)
129
s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
130
s->use_color = -1;
131
s->relative_paths = 1;
132
- s->branch = resolve_refdup("HEAD", 0, sha1, NULL);
132
+ s->branch = resolve_refdup("HEAD", 0, oid.hash, NULL);
133
s->reference = "HEAD";
134
s->fp = stdout;
135
s->index_file = get_index_file();