Merge branch 'rs/resolve-ref-optional-result'
authorJunio C Hamano <gitster@pobox.com>
Thu, 5 Oct 2017 04:48:19 +0000 (13:48 +0900)
committerJunio C Hamano <gitster@pobox.com>
Thu, 5 Oct 2017 04:48:19 +0000 (13:48 +0900)
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

builtin/checkout.c
builtin/receive-pack.c
ref-filter.c
reflog-walk.c
refs/files-backend.c
transport.c
wt-status.c
index 3345a0d16f21c38fe5fe6f32fa5b0a139e21c4a3..10751585ea38c282d439e4128c895c01a2598985 100644 (file)
@@ -1124,9 +1124,8 @@ static int checkout_branch(struct checkout_opts *opts,
 
        if (new->path && !opts->force_detach && !opts->new_branch &&
            !opts->ignore_other_worktrees) {
-               struct object_id oid;
                int flag;
-               char *head_ref = resolve_refdup("HEAD", 0, oid.hash, &flag);
+               char *head_ref = resolve_refdup("HEAD", 0, NULL, &flag);
                if (head_ref &&
                    (!(flag & REF_ISSYMREF) || strcmp(head_ref, new->path)))
                        die_if_checked_out(new->path, 1);
index 29a0f3b75fb02dfa2a02c325816453e36baaa55a..cc4876740569c6e495b7cb32161d019619171d79 100644 (file)
@@ -1458,7 +1458,6 @@ static void execute_commands(struct command *commands,
 {
        struct check_connected_options opt = CHECK_CONNECTED_INIT;
        struct command *cmd;
-       struct object_id oid;
        struct iterate_data data;
        struct async muxer;
        int err_fd = 0;
@@ -1515,7 +1514,7 @@ static void execute_commands(struct command *commands,
        check_aliased_updates(commands);
 
        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)
                execute_commands_atomic(commands, si);
index bc591f4f3de0c07b0cfe3813d5d9daaf1ad44b63..55323620ab2aedc443989a876b4f4c43df6115cf 100644 (file)
@@ -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)
 {
-       struct object_id unused;
-
-       atom->u.head = resolve_refdup("HEAD", RESOLVE_REF_READING, unused.hash, NULL);
+       atom->u.head = resolve_refdup("HEAD", RESOLVE_REF_READING, NULL, NULL);
 }
 
 static struct {
@@ -1317,9 +1315,8 @@ static void populate_value(struct ref_array_item *ref)
        ref->value = xcalloc(used_atom_cnt, sizeof(struct atom_value));
 
        if (need_symref && (ref->flag & REF_ISSYMREF) && !ref->symref) {
-               struct object_id unused1;
                ref->symref = resolve_refdup(ref->refname, RESOLVE_REF_READING,
-                                            unused1.hash, NULL);
+                                            NULL, NULL);
                if (!ref->symref)
                        ref->symref = "";
        }
index 74ebe5148f6623f0bffd612262519266a8ab2cc4..842b2f77dc3e40a2eb296bfade00d9d2104ff9e1 100644 (file)
@@ -61,11 +61,10 @@ static struct complete_reflogs *read_complete_reflog(const char *ref)
        reflogs->ref = xstrdup(ref);
        for_each_reflog_ent(ref, read_one_reflog, reflogs);
        if (reflogs->nr == 0) {
-               struct object_id oid;
                const char *name;
                void *name_to_free;
                name = name_to_free = resolve_refdup(ref, RESOLVE_REF_READING,
-                                                    oid.hash, NULL);
+                                                    NULL, NULL);
                if (name) {
                        for_each_reflog_ent(name, read_one_reflog, reflogs);
                        free(name_to_free);
@@ -151,9 +150,8 @@ int add_reflog_for_walk(struct reflog_walk_info *info,
                reflogs = item->util;
        else {
                if (*branch == '\0') {
-                       struct object_id oid;
                        free(branch);
-                       branch = resolve_refdup("HEAD", 0, oid.hash, NULL);
+                       branch = resolve_refdup("HEAD", 0, NULL, NULL);
                        if (!branch)
                                die ("No current branch");
 
index 1b6141e718a5c449226c22fdeefb80b591ca3f7e..014dabb0bf3647b9392d6087ebf6c40e1bc68108 100644 (file)
@@ -2494,7 +2494,6 @@ static int files_transaction_prepare(struct ref_store *ref_store,
        struct string_list affected_refnames = STRING_LIST_INIT_NODUP;
        char *head_ref = NULL;
        int head_type;
-       struct object_id head_oid;
        struct files_transaction_backend_data *backend_data;
        struct ref_transaction *packed_transaction = NULL;
 
@@ -2551,7 +2550,7 @@ static int files_transaction_prepare(struct ref_store *ref_store,
         */
        head_ref = refs_resolve_refdup(ref_store, "HEAD",
                                       RESOLVE_REF_NO_RECURSE,
-                                      head_oid.hash, &head_type);
+                                      NULL, &head_type);
 
        if (head_ref && !(head_type & REF_ISSYMREF)) {
                FREE_AND_NULL(head_ref);
index fb8c01e57a99f35f63690c536e3f623d3695b1de..f1e2f61991424f3314158676754f6b8d305a31f2 100644 (file)
@@ -471,11 +471,10 @@ void transport_print_push_status(const char *dest, struct ref *refs,
 {
        struct ref *ref;
        int n = 0;
-       struct object_id head_oid;
        char *head;
        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) {
                for (ref = refs; ref; ref = ref->next)
index 6f730ee8f22b958c7502656d2e1d01ea1f932396..29bc64cc0280675065142bac257930904216d415 100644 (file)
@@ -121,15 +121,13 @@ static void status_printf_more(struct wt_status *s, const char *color,
 
 void wt_status_prepare(struct wt_status *s)
 {
-       struct object_id oid;
-
        memset(s, 0, sizeof(*s));
        memcpy(s->color_palette, default_wt_status_colors,
               sizeof(default_wt_status_colors));
        s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
        s->use_color = -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->fp = stdout;
        s->index_file = get_index_file();