line-range.h: drop extern from function declaration
[gitweb.git] / builtin / checkout.c
index 2de10d28c76e7616748ef37def3b6e4f43a4e7a7..516136a23a3d6962703186ca825e416cb653e677 100644 (file)
@@ -79,7 +79,7 @@ static int update_some(const struct object_id *oid, struct strbuf *base,
                return READ_TREE_RECURSIVE;
 
        len = base->len + strlen(pathname);
-       ce = xcalloc(1, cache_entry_size(len));
+       ce = make_empty_cache_entry(&the_index, len);
        oidcpy(&ce->oid, oid);
        memcpy(ce->name, base->buf, base->len);
        memcpy(ce->name + base->len, pathname, len - base->len);
@@ -98,7 +98,7 @@ static int update_some(const struct object_id *oid, struct strbuf *base,
                if (ce->ce_mode == old->ce_mode &&
                    !oidcmp(&ce->oid, &old->oid)) {
                        old->ce_flags |= CE_UPDATE;
-                       free(ce);
+                       discard_cache_entry(ce);
                        return 0;
                }
        }
@@ -232,11 +232,11 @@ static int checkout_merged(int pos, const struct checkout *state)
        if (write_object_file(result_buf.ptr, result_buf.size, blob_type, &oid))
                die(_("Unable to add merge result for '%s'"), path);
        free(result_buf.ptr);
-       ce = make_cache_entry(mode, oid.hash, path, 2, 0);
+       ce = make_transient_cache_entry(mode, &oid, path, 2);
        if (!ce)
                die(_("make_cache_entry failed for path '%s'"), path);
        status = checkout_entry(ce, state, NULL);
-       free(ce);
+       discard_cache_entry(ce);
        return status;
 }
 
@@ -380,7 +380,7 @@ static int checkout_paths(const struct checkout_opts *opts,
                die(_("unable to write new index file"));
 
        read_ref_full("HEAD", 0, &rev, NULL);
-       head = lookup_commit_reference_gently(&rev, 1);
+       head = lookup_commit_reference_gently(the_repository, &rev, 1);
 
        errs |= post_checkout_hook(head, head, 0);
        return errs;
@@ -831,7 +831,7 @@ static int switch_branches(const struct checkout_opts *opts,
        memset(&old_branch_info, 0, sizeof(old_branch_info));
        old_branch_info.path = path_to_free = resolve_refdup("HEAD", 0, &rev, &flag);
        if (old_branch_info.path)
-               old_branch_info.commit = lookup_commit_reference_gently(&rev, 1);
+               old_branch_info.commit = lookup_commit_reference_gently(the_repository, &rev, 1);
        if (!(flag & REF_ISSYMREF))
                old_branch_info.path = NULL;
 
@@ -1009,7 +1009,7 @@ static int parse_branchname_arg(int argc, const char **argv,
        else
                new_branch_info->path = NULL; /* not an existing branch */
 
-       new_branch_info->commit = lookup_commit_reference_gently(rev, 1);
+       new_branch_info->commit = lookup_commit_reference_gently(the_repository, rev, 1);
        if (!new_branch_info->commit) {
                /* not a commit */
                *source_tree = parse_tree_indirect(rev);