refs: pass NULL to resolve_refdup() if hash is not needed

This allows us to get rid of several write-only variables. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Oct 1, 2017 at 09:29 UTC efbd4fdfc9978bf3872ca8cf390da4ffa3480188
6 files changed +8 -18
builtin/checkout.c
+1 -2
@@ -1116,9 +1116,8 @@ static int checkout_branch(struct checkout_opts *opts,
1116
1117 if (new->path && !opts->force_detach && !opts->new_branch &&
1118 !opts->ignore_other_worktrees) {
1119 - struct object_id oid;
1119 int flag;
1121 - char *head_ref = resolve_refdup("HEAD", 0, oid.hash, &flag);
1120 + char *head_ref = resolve_refdup("HEAD", 0, NULL, &flag);
1121 if (head_ref &&
1122 (!(flag & REF_ISSYMREF) || strcmp(head_ref, new->path)))
1123 die_if_checked_out(new->path, 1);
builtin/receive-pack.c
+1 -2
@@ -1458,7 +1458,6 @@ static void execute_commands(struct command *commands,
1458 {
1459 struct check_connected_options opt = CHECK_CONNECTED_INIT;
1460 struct command *cmd;
1461 - struct object_id oid;
1461 struct iterate_data data;
1462 struct async muxer;
1463 int err_fd = 0;
@@ -1515,7 +1514,7 @@ static void execute_commands(struct command *commands,
1514 check_aliased_updates(commands);
1515
1516 free(head_name_to_free);
1518 - head_name = head_name_to_free = resolve_refdup("HEAD", 0, oid.hash, NULL);
1517 + head_name = head_name_to_free = resolve_refdup("HEAD", 0, NULL, NULL);
1518
1519 if (use_atomic)
1520 execute_commands_atomic(commands, si);
ref-filter.c
+2 -5
@@ -295,9 +295,7 @@ static void if_atom_parser(const struct ref_format *format, struct used_atom *at
295
296 static void head_atom_parser(const struct ref_format *format, struct used_atom *atom, const char *arg)
297 {
298 - struct object_id unused;
299 -
300 - atom->u.head = resolve_refdup("HEAD", RESOLVE_REF_READING, unused.hash, NULL);
298 + atom->u.head = resolve_refdup("HEAD", RESOLVE_REF_READING, NULL, NULL);
299 }
300
301 static struct {
@@ -1317,9 +1315,8 @@ static void populate_value(struct ref_array_item *ref)
1315 ref->value = xcalloc(used_atom_cnt, sizeof(struct atom_value));
1316
1317 if (need_symref && (ref->flag & REF_ISSYMREF) && !ref->symref) {
1320 - struct object_id unused1;
1318 ref->symref = resolve_refdup(ref->refname, RESOLVE_REF_READING,
1322 - unused1.hash, NULL);
1319 + NULL, NULL);
1320 if (!ref->symref)
1321 ref->symref = "";
1322 }
reflog-walk.c
+2 -4
@@ -61,11 +61,10 @@ static struct complete_reflogs *read_complete_reflog(const char *ref)
61 reflogs->ref = xstrdup(ref);
62 for_each_reflog_ent(ref, read_one_reflog, reflogs);
63 if (reflogs->nr == 0) {
64 - struct object_id oid;
64 const char *name;
65 void *name_to_free;
66 name = name_to_free = resolve_refdup(ref, RESOLVE_REF_READING,
68 - oid.hash, NULL);
67 + NULL, NULL);
68 if (name) {
69 for_each_reflog_ent(name, read_one_reflog, reflogs);
70 free(name_to_free);
@@ -151,9 +150,8 @@ int add_reflog_for_walk(struct reflog_walk_info *info,
150 reflogs = item->util;
151 else {
152 if (*branch == '\0') {
154 - struct object_id oid;
153 free(branch);
156 - branch = resolve_refdup("HEAD", 0, oid.hash, NULL);
154 + branch = resolve_refdup("HEAD", 0, NULL, NULL);
155 if (!branch)
156 die ("No current branch");
157
transport.c
+1 -2
@@ -471,11 +471,10 @@ void transport_print_push_status(const char *dest, struct ref *refs,
471 {
472 struct ref *ref;
473 int n = 0;
474 - struct object_id head_oid;
474 char *head;
475 int summary_width = transport_summary_width(refs);
476
478 - head = resolve_refdup("HEAD", RESOLVE_REF_READING, head_oid.hash, NULL);
477 + head = resolve_refdup("HEAD", RESOLVE_REF_READING, NULL, NULL);
478
479 if (verbose) {
480 for (ref = refs; ref; ref = ref->next)
wt-status.c
+1 -3
@@ -121,15 +121,13 @@ static void status_printf_more(struct wt_status *s, const char *color,
121
122 void wt_status_prepare(struct wt_status *s)
123 {
124 - struct object_id oid;
125 -
124 memset(s, 0, sizeof(*s));
125 memcpy(s->color_palette, default_wt_status_colors,
126 sizeof(default_wt_status_colors));
127 s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
128 s->use_color = -1;
129 s->relative_paths = 1;
132 - s->branch = resolve_refdup("HEAD", 0, oid.hash, NULL);
130 + s->branch = resolve_refdup("HEAD", 0, NULL, NULL);
131 s->reference = "HEAD";
132 s->fp = stdout;
133 s->index_file = get_index_file();