Convert remaining callers of resolve_refdup to object_id
authorbrian m. carlson <sandals@crustytoothpaste.net>
Tue, 21 Feb 2017 23:47:29 +0000 (23:47 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 22 Feb 2017 18:12:15 +0000 (10:12 -0800)
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>
builtin/notes.c
builtin/receive-pack.c
ref-filter.c
reflog-walk.c
transport.c
wt-status.c
index 5248a9bad8d4d18c8ff0f145e8049606baa8849a..8c569a49a0635e163c38351affd7e91bd5fd2135 100644 (file)
@@ -693,7 +693,7 @@ static int merge_abort(struct notes_merge_options *o)
 static int merge_commit(struct notes_merge_options *o)
 {
        struct strbuf msg = STRBUF_INIT;
-       unsigned char sha1[20], parent_sha1[20];
+       struct object_id oid, parent_oid;
        struct notes_tree *t;
        struct commit *partial;
        struct pretty_print_context pretty_ctx;
@@ -705,27 +705,27 @@ static int merge_commit(struct notes_merge_options *o)
         * and target notes ref from .git/NOTES_MERGE_REF.
         */
 
-       if (get_sha1("NOTES_MERGE_PARTIAL", sha1))
+       if (get_oid("NOTES_MERGE_PARTIAL", &oid))
                die(_("failed to read ref NOTES_MERGE_PARTIAL"));
-       else if (!(partial = lookup_commit_reference(sha1)))
+       else if (!(partial = lookup_commit_reference(oid.hash)))
                die(_("could not find commit from NOTES_MERGE_PARTIAL."));
        else if (parse_commit(partial))
                die(_("could not parse commit from NOTES_MERGE_PARTIAL."));
 
        if (partial->parents)
-               hashcpy(parent_sha1, partial->parents->item->object.oid.hash);
+               oidcpy(&parent_oid, &partial->parents->item->object.oid);
        else
-               hashclr(parent_sha1);
+               oidclr(&parent_oid);
 
        t = xcalloc(1, sizeof(struct notes_tree));
        init_notes(t, "NOTES_MERGE_PARTIAL", combine_notes_overwrite, 0);
 
        o->local_ref = local_ref_to_free =
-               resolve_refdup("NOTES_MERGE_REF", 0, sha1, NULL);
+               resolve_refdup("NOTES_MERGE_REF", 0, oid.hash, NULL);
        if (!o->local_ref)
                die(_("failed to resolve NOTES_MERGE_REF"));
 
-       if (notes_merge_commit(o, t, partial, sha1))
+       if (notes_merge_commit(o, t, partial, oid.hash))
                die(_("failed to finalize notes merge"));
 
        /* Reuse existing commit message in reflog message */
@@ -733,8 +733,8 @@ static int merge_commit(struct notes_merge_options *o)
        format_commit_message(partial, "%s", &msg, &pretty_ctx);
        strbuf_trim(&msg);
        strbuf_insert(&msg, 0, "notes: ", 7);
-       update_ref(msg.buf, o->local_ref, sha1,
-                  is_null_sha1(parent_sha1) ? NULL : parent_sha1,
+       update_ref(msg.buf, o->local_ref, oid.hash,
+                  is_null_oid(&parent_oid) ? NULL : parent_oid.hash,
                   0, UPDATE_REFS_DIE_ON_ERR);
 
        free_notes(t);
index 1dbb8a069225be1e9d9fe27ad4b83a8bd66ca511..7966f4f4df012d53283cbeca036733c9cd54b6a0 100644 (file)
@@ -1414,7 +1414,7 @@ static void execute_commands(struct command *commands,
 {
        struct check_connected_options opt = CHECK_CONNECTED_INIT;
        struct command *cmd;
-       unsigned char sha1[20];
+       struct object_id oid;
        struct iterate_data data;
        struct async muxer;
        int err_fd = 0;
@@ -1471,7 +1471,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, sha1, NULL);
+       head_name = head_name_to_free = resolve_refdup("HEAD", 0, oid.hash, NULL);
 
        if (use_atomic)
                execute_commands_atomic(commands, si);
index 3820b21cc75f5e7fd4b1b1851be0aaa9e3268d7d..f0de30e2efead63ad33815ece61a9ee6ca8a2b85 100644 (file)
@@ -961,9 +961,9 @@ 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) {
-               unsigned char unused1[20];
+               struct object_id unused1;
                ref->symref = resolve_refdup(ref->refname, RESOLVE_REF_READING,
-                                            unused1, NULL);
+                                            unused1.hash, NULL);
                if (!ref->symref)
                        ref->symref = "";
        }
index a246af27678a76d37c87bb56959ac050dff1f97f..f98748e2aea4a390f23174d179f3d2b1c73fa836 100644 (file)
@@ -45,11 +45,11 @@ 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) {
-               unsigned char sha1[20];
+               struct object_id oid;
                const char *name;
                void *name_to_free;
                name = name_to_free = resolve_refdup(ref, RESOLVE_REF_READING,
-                                                    sha1, NULL);
+                                                    oid.hash, NULL);
                if (name) {
                        for_each_reflog_ent(name, read_one_reflog, reflogs);
                        free(name_to_free);
@@ -172,18 +172,18 @@ int add_reflog_for_walk(struct reflog_walk_info *info,
                reflogs = item->util;
        else {
                if (*branch == '\0') {
-                       unsigned char sha1[20];
+                       struct object_id oid;
                        free(branch);
-                       branch = resolve_refdup("HEAD", 0, sha1, NULL);
+                       branch = resolve_refdup("HEAD", 0, oid.hash, NULL);
                        if (!branch)
                                die ("No current branch");
 
                }
                reflogs = read_complete_reflog(branch);
                if (!reflogs || reflogs->nr == 0) {
-                       unsigned char sha1[20];
+                       struct object_id oid;
                        char *b;
-                       if (dwim_log(branch, strlen(branch), sha1, &b) == 1) {
+                       if (dwim_log(branch, strlen(branch), oid.hash, &b) == 1) {
                                if (reflogs) {
                                        free(reflogs->ref);
                                        free(reflogs);
index d72e0894840fc384d67339b549a9a6bce7ba03ec..141af31e8e314858217f986df0363372a7a7b99d 100644 (file)
@@ -467,11 +467,11 @@ void transport_print_push_status(const char *dest, struct ref *refs,
 {
        struct ref *ref;
        int n = 0;
-       unsigned char head_sha1[20];
+       struct object_id head_oid;
        char *head;
        int summary_width = transport_summary_width(refs);
 
-       head = resolve_refdup("HEAD", RESOLVE_REF_READING, head_sha1, NULL);
+       head = resolve_refdup("HEAD", RESOLVE_REF_READING, head_oid.hash, NULL);
 
        if (verbose) {
                for (ref = refs; ref; ref = ref->next)
index d47012048f81c92a82758d87f8726cb919501104..0ec090a3387a61e33517f2676226b03384dc52b7 100644 (file)
@@ -121,7 +121,7 @@ static void status_printf_more(struct wt_status *s, const char *color,
 
 void wt_status_prepare(struct wt_status *s)
 {
-       unsigned char sha1[20];
+       struct object_id oid;
 
        memset(s, 0, sizeof(*s));
        memcpy(s->color_palette, default_wt_status_colors,
@@ -129,7 +129,7 @@ void wt_status_prepare(struct wt_status *s)
        s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
        s->use_color = -1;
        s->relative_paths = 1;
-       s->branch = resolve_refdup("HEAD", 0, sha1, NULL);
+       s->branch = resolve_refdup("HEAD", 0, oid.hash, NULL);
        s->reference = "HEAD";
        s->fp = stdout;
        s->index_file = get_index_file();