Commit efbd4fdf authored by René Scharfe's avatar René Scharfe Committed by Junio C Hamano

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: default avatarRene Scharfe <l.s.r@web.de>
Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
parent 872ccb2c
...@@ -1116,9 +1116,8 @@ static int checkout_branch(struct checkout_opts *opts, ...@@ -1116,9 +1116,8 @@ static int checkout_branch(struct checkout_opts *opts,
if (new->path && !opts->force_detach && !opts->new_branch && if (new->path && !opts->force_detach && !opts->new_branch &&
!opts->ignore_other_worktrees) { !opts->ignore_other_worktrees) {
struct object_id oid;
int flag; int flag;
char *head_ref = resolve_refdup("HEAD", 0, oid.hash, &flag); char *head_ref = resolve_refdup("HEAD", 0, NULL, &flag);
if (head_ref && if (head_ref &&
(!(flag & REF_ISSYMREF) || strcmp(head_ref, new->path))) (!(flag & REF_ISSYMREF) || strcmp(head_ref, new->path)))
die_if_checked_out(new->path, 1); die_if_checked_out(new->path, 1);
......
...@@ -1458,7 +1458,6 @@ static void execute_commands(struct command *commands, ...@@ -1458,7 +1458,6 @@ static void execute_commands(struct command *commands,
{ {
struct check_connected_options opt = CHECK_CONNECTED_INIT; struct check_connected_options opt = CHECK_CONNECTED_INIT;
struct command *cmd; struct command *cmd;
struct object_id oid;
struct iterate_data data; struct iterate_data data;
struct async muxer; struct async muxer;
int err_fd = 0; int err_fd = 0;
...@@ -1515,7 +1514,7 @@ static void execute_commands(struct command *commands, ...@@ -1515,7 +1514,7 @@ static void execute_commands(struct command *commands,
check_aliased_updates(commands); check_aliased_updates(commands);
free(head_name_to_free); free(head_name_to_free);
head_name = head_name_to_free = resolve_refdup("HEAD", 0, oid.hash, NULL); head_name = head_name_to_free = resolve_refdup("HEAD", 0, NULL, NULL);
if (use_atomic) if (use_atomic)
execute_commands_atomic(commands, si); execute_commands_atomic(commands, si);
......
...@@ -295,9 +295,7 @@ static void if_atom_parser(const struct ref_format *format, struct used_atom *at ...@@ -295,9 +295,7 @@ static void if_atom_parser(const struct ref_format *format, struct used_atom *at
static void head_atom_parser(const struct ref_format *format, struct used_atom *atom, const char *arg) static void head_atom_parser(const struct ref_format *format, struct used_atom *atom, const char *arg)
{ {
struct object_id unused; atom->u.head = resolve_refdup("HEAD", RESOLVE_REF_READING, NULL, NULL);
atom->u.head = resolve_refdup("HEAD", RESOLVE_REF_READING, unused.hash, NULL);
} }
static struct { static struct {
...@@ -1317,9 +1315,8 @@ static void populate_value(struct ref_array_item *ref) ...@@ -1317,9 +1315,8 @@ static void populate_value(struct ref_array_item *ref)
ref->value = xcalloc(used_atom_cnt, sizeof(struct atom_value)); ref->value = xcalloc(used_atom_cnt, sizeof(struct atom_value));
if (need_symref && (ref->flag & REF_ISSYMREF) && !ref->symref) { if (need_symref && (ref->flag & REF_ISSYMREF) && !ref->symref) {
struct object_id unused1;
ref->symref = resolve_refdup(ref->refname, RESOLVE_REF_READING, ref->symref = resolve_refdup(ref->refname, RESOLVE_REF_READING,
unused1.hash, NULL); NULL, NULL);
if (!ref->symref) if (!ref->symref)
ref->symref = ""; ref->symref = "";
} }
......
...@@ -61,11 +61,10 @@ static struct complete_reflogs *read_complete_reflog(const char *ref) ...@@ -61,11 +61,10 @@ static struct complete_reflogs *read_complete_reflog(const char *ref)
reflogs->ref = xstrdup(ref); reflogs->ref = xstrdup(ref);
for_each_reflog_ent(ref, read_one_reflog, reflogs); for_each_reflog_ent(ref, read_one_reflog, reflogs);
if (reflogs->nr == 0) { if (reflogs->nr == 0) {
struct object_id oid;
const char *name; const char *name;
void *name_to_free; void *name_to_free;
name = name_to_free = resolve_refdup(ref, RESOLVE_REF_READING, name = name_to_free = resolve_refdup(ref, RESOLVE_REF_READING,
oid.hash, NULL); NULL, NULL);
if (name) { if (name) {
for_each_reflog_ent(name, read_one_reflog, reflogs); for_each_reflog_ent(name, read_one_reflog, reflogs);
free(name_to_free); free(name_to_free);
...@@ -151,9 +150,8 @@ int add_reflog_for_walk(struct reflog_walk_info *info, ...@@ -151,9 +150,8 @@ int add_reflog_for_walk(struct reflog_walk_info *info,
reflogs = item->util; reflogs = item->util;
else { else {
if (*branch == '\0') { if (*branch == '\0') {
struct object_id oid;
free(branch); free(branch);
branch = resolve_refdup("HEAD", 0, oid.hash, NULL); branch = resolve_refdup("HEAD", 0, NULL, NULL);
if (!branch) if (!branch)
die ("No current branch"); die ("No current branch");
......
...@@ -471,11 +471,10 @@ void transport_print_push_status(const char *dest, struct ref *refs, ...@@ -471,11 +471,10 @@ void transport_print_push_status(const char *dest, struct ref *refs,
{ {
struct ref *ref; struct ref *ref;
int n = 0; int n = 0;
struct object_id head_oid;
char *head; char *head;
int summary_width = transport_summary_width(refs); int summary_width = transport_summary_width(refs);
head = resolve_refdup("HEAD", RESOLVE_REF_READING, head_oid.hash, NULL); head = resolve_refdup("HEAD", RESOLVE_REF_READING, NULL, NULL);
if (verbose) { if (verbose) {
for (ref = refs; ref; ref = ref->next) for (ref = refs; ref; ref = ref->next)
......
...@@ -121,15 +121,13 @@ static void status_printf_more(struct wt_status *s, const char *color, ...@@ -121,15 +121,13 @@ static void status_printf_more(struct wt_status *s, const char *color,
void wt_status_prepare(struct wt_status *s) void wt_status_prepare(struct wt_status *s)
{ {
struct object_id oid;
memset(s, 0, sizeof(*s)); memset(s, 0, sizeof(*s));
memcpy(s->color_palette, default_wt_status_colors, memcpy(s->color_palette, default_wt_status_colors,
sizeof(default_wt_status_colors)); sizeof(default_wt_status_colors));
s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES; s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
s->use_color = -1; s->use_color = -1;
s->relative_paths = 1; s->relative_paths = 1;
s->branch = resolve_refdup("HEAD", 0, oid.hash, NULL); s->branch = resolve_refdup("HEAD", 0, NULL, NULL);
s->reference = "HEAD"; s->reference = "HEAD";
s->fp = stdout; s->fp = stdout;
s->index_file = get_index_file(); s->index_file = get_index_file();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment