Skip to content

Commit efe9d6c

Browse files
committed
Merge branch 'rs/resolve-ref-optional-result'
Code clean-up. * rs/resolve-ref-optional-result: refs: pass NULL to resolve_refdup() if hash is not needed refs: pass NULL to refs_resolve_refdup() if hash is not needed
2 parents 29a67cc + efbd4fd commit efe9d6c

File tree

7 files changed

+9
-20
lines changed

7 files changed

+9
-20
lines changed

builtin/checkout.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,9 +1124,8 @@ static int checkout_branch(struct checkout_opts *opts,
11241124

11251125
if (new->path && !opts->force_detach && !opts->new_branch &&
11261126
!opts->ignore_other_worktrees) {
1127-
struct object_id oid;
11281127
int flag;
1129-
char *head_ref = resolve_refdup("HEAD", 0, oid.hash, &flag);
1128+
char *head_ref = resolve_refdup("HEAD", 0, NULL, &flag);
11301129
if (head_ref &&
11311130
(!(flag & REF_ISSYMREF) || strcmp(head_ref, new->path)))
11321131
die_if_checked_out(new->path, 1);

builtin/receive-pack.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,6 @@ static void execute_commands(struct command *commands,
14581458
{
14591459
struct check_connected_options opt = CHECK_CONNECTED_INIT;
14601460
struct command *cmd;
1461-
struct object_id oid;
14621461
struct iterate_data data;
14631462
struct async muxer;
14641463
int err_fd = 0;
@@ -1515,7 +1514,7 @@ static void execute_commands(struct command *commands,
15151514
check_aliased_updates(commands);
15161515

15171516
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);
15191518

15201519
if (use_atomic)
15211520
execute_commands_atomic(commands, si);

ref-filter.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,7 @@ static void if_atom_parser(const struct ref_format *format, struct used_atom *at
295295

296296
static void head_atom_parser(const struct ref_format *format, struct used_atom *atom, const char *arg)
297297
{
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);
301299
}
302300

303301
static struct {
@@ -1317,9 +1315,8 @@ static void populate_value(struct ref_array_item *ref)
13171315
ref->value = xcalloc(used_atom_cnt, sizeof(struct atom_value));
13181316

13191317
if (need_symref && (ref->flag & REF_ISSYMREF) && !ref->symref) {
1320-
struct object_id unused1;
13211318
ref->symref = resolve_refdup(ref->refname, RESOLVE_REF_READING,
1322-
unused1.hash, NULL);
1319+
NULL, NULL);
13231320
if (!ref->symref)
13241321
ref->symref = "";
13251322
}

reflog-walk.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,10 @@ static struct complete_reflogs *read_complete_reflog(const char *ref)
6161
reflogs->ref = xstrdup(ref);
6262
for_each_reflog_ent(ref, read_one_reflog, reflogs);
6363
if (reflogs->nr == 0) {
64-
struct object_id oid;
6564
const char *name;
6665
void *name_to_free;
6766
name = name_to_free = resolve_refdup(ref, RESOLVE_REF_READING,
68-
oid.hash, NULL);
67+
NULL, NULL);
6968
if (name) {
7069
for_each_reflog_ent(name, read_one_reflog, reflogs);
7170
free(name_to_free);
@@ -151,9 +150,8 @@ int add_reflog_for_walk(struct reflog_walk_info *info,
151150
reflogs = item->util;
152151
else {
153152
if (*branch == '\0') {
154-
struct object_id oid;
155153
free(branch);
156-
branch = resolve_refdup("HEAD", 0, oid.hash, NULL);
154+
branch = resolve_refdup("HEAD", 0, NULL, NULL);
157155
if (!branch)
158156
die ("No current branch");
159157

refs/files-backend.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2494,7 +2494,6 @@ static int files_transaction_prepare(struct ref_store *ref_store,
24942494
struct string_list affected_refnames = STRING_LIST_INIT_NODUP;
24952495
char *head_ref = NULL;
24962496
int head_type;
2497-
struct object_id head_oid;
24982497
struct files_transaction_backend_data *backend_data;
24992498
struct ref_transaction *packed_transaction = NULL;
25002499

@@ -2551,7 +2550,7 @@ static int files_transaction_prepare(struct ref_store *ref_store,
25512550
*/
25522551
head_ref = refs_resolve_refdup(ref_store, "HEAD",
25532552
RESOLVE_REF_NO_RECURSE,
2554-
head_oid.hash, &head_type);
2553+
NULL, &head_type);
25552554

25562555
if (head_ref && !(head_type & REF_ISSYMREF)) {
25572556
FREE_AND_NULL(head_ref);

transport.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,11 +471,10 @@ void transport_print_push_status(const char *dest, struct ref *refs,
471471
{
472472
struct ref *ref;
473473
int n = 0;
474-
struct object_id head_oid;
475474
char *head;
476475
int summary_width = transport_summary_width(refs);
477476

478-
head = resolve_refdup("HEAD", RESOLVE_REF_READING, head_oid.hash, NULL);
477+
head = resolve_refdup("HEAD", RESOLVE_REF_READING, NULL, NULL);
479478

480479
if (verbose) {
481480
for (ref = refs; ref; ref = ref->next)

wt-status.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,13 @@ static void status_printf_more(struct wt_status *s, const char *color,
121121

122122
void wt_status_prepare(struct wt_status *s)
123123
{
124-
struct object_id oid;
125-
126124
memset(s, 0, sizeof(*s));
127125
memcpy(s->color_palette, default_wt_status_colors,
128126
sizeof(default_wt_status_colors));
129127
s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
130128
s->use_color = -1;
131129
s->relative_paths = 1;
132-
s->branch = resolve_refdup("HEAD", 0, oid.hash, NULL);
130+
s->branch = resolve_refdup("HEAD", 0, NULL, NULL);
133131
s->reference = "HEAD";
134132
s->fp = stdout;
135133
s->index_file = get_index_file();

0 commit comments

Comments
 (0)