read-cache: teach make_cache_entry to take object_id
authorJameson Miller <jamill@microsoft.com>
Mon, 2 Jul 2018 19:49:30 +0000 (19:49 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 Jul 2018 17:58:15 +0000 (10:58 -0700)
Teach make_cache_entry function to take object_id instead of a SHA-1.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
apply.c
builtin/checkout.c
builtin/difftool.c
builtin/reset.c
cache.h
merge-recursive.c
read-cache.c
resolve-undo.c
diff --git a/apply.c b/apply.c
index d79e61591b3814339fb8b2a39fb7d1e211d622c6..5dd634ceaf49fdbc042a09e04d47013c56c3f814 100644 (file)
--- a/apply.c
+++ b/apply.c
@@ -4090,7 +4090,7 @@ static int build_fake_ancestor(struct apply_state *state, struct patch *list)
                        return error(_("sha1 information is lacking or useless "
                                       "(%s)."), name);
 
-               ce = make_cache_entry(patch->old_mode, oid.hash, name, 0, 0);
+               ce = make_cache_entry(patch->old_mode, &oid, name, 0, 0);
                if (!ce)
                        return error(_("make_cache_entry failed for path '%s'"),
                                     name);
index 2e1d2376d24043a75adb9bbc69724591bcc2d5c3..548bf40f2549a85afc8bd0bfa55a8286017b5802 100644 (file)
@@ -230,7 +230,7 @@ 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_cache_entry(mode, &oid, path, 2, 0);
        if (!ce)
                die(_("make_cache_entry failed for path '%s'"), path);
        status = checkout_entry(ce, state, NULL);
index bc97d4aef2db2d76e3ffddfc4759e52688f3974e..873a06f0d90f35456d31a28f68ab10c71354e5c9 100644 (file)
@@ -321,7 +321,7 @@ static int checkout_path(unsigned mode, struct object_id *oid,
        struct cache_entry *ce;
        int ret;
 
-       ce = make_cache_entry(mode, oid->hash, path, 0, 0);
+       ce = make_cache_entry(mode, oid, path, 0, 0);
        ret = checkout_entry(ce, state, NULL);
 
        free(ce);
@@ -488,7 +488,7 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
                                 * index.
                                 */
                                struct cache_entry *ce2 =
-                                       make_cache_entry(rmode, roid.hash,
+                                       make_cache_entry(rmode, &roid,
                                                         dst_path, 0, 0);
 
                                add_index_entry(&wtindex, ce2,
index a862c70fab99290b5faf3e700e88194589583329..00109b041f9130dbd8d0e908032bfb60c3e1552b 100644 (file)
@@ -134,7 +134,7 @@ static void update_index_from_diff(struct diff_queue_struct *q,
                        continue;
                }
 
-               ce = make_cache_entry(one->mode, one->oid.hash, one->path,
+               ce = make_cache_entry(one->mode, &one->oid, one->path,
                                      0, 0);
                if (!ce)
                        die(_("make_cache_entry failed for path '%s'"),
diff --git a/cache.h b/cache.h
index 9538511d9fe99a2a41e69df60edae739cd94ab6f..7953d52caa04c1068101408802947d843e438694 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -698,7 +698,12 @@ extern int remove_file_from_index(struct index_state *, const char *path);
 extern int add_to_index(struct index_state *, const char *path, struct stat *, int flags);
 extern int add_file_to_index(struct index_state *, const char *path, int flags);
 
-extern struct cache_entry *make_cache_entry(unsigned int mode, const unsigned char *sha1, const char *path, int stage, unsigned int refresh_options);
+extern struct cache_entry *make_cache_entry(unsigned int mode,
+                                           const struct object_id *oid,
+                                           const char *path,
+                                           int stage,
+                                           unsigned int refresh_options);
+
 extern int chmod_index_entry(struct index_state *, struct cache_entry *ce, char flip);
 extern int ce_same_name(const struct cache_entry *a, const struct cache_entry *b);
 extern void set_object_name_for_intent_to_add_entry(struct cache_entry *ce);
index 11a767cc72541b5a01b59c4da89ff0861c1f1be6..8b30cc7e35e5f5cccd5e12477da0dc904bd3ad98 100644 (file)
@@ -315,7 +315,7 @@ static int add_cacheinfo(struct merge_options *o,
        struct cache_entry *ce;
        int ret;
 
-       ce = make_cache_entry(mode, oid ? oid->hash : null_sha1, path, stage, 0);
+       ce = make_cache_entry(mode, oid ? oid : &null_oid, path, stage, 0);
        if (!ce)
                return err(o, _("add_cacheinfo failed for path '%s'; merge aborting."), path);
 
index fa8366ecab586122a9c1ca0b2c77bc614877bc7c..c12664c78966d0ce5d5403ce79c095e5aa42d408 100644 (file)
@@ -746,8 +746,10 @@ int add_file_to_index(struct index_state *istate, const char *path, int flags)
 }
 
 struct cache_entry *make_cache_entry(unsigned int mode,
-               const unsigned char *sha1, const char *path, int stage,
-               unsigned int refresh_options)
+                                    const struct object_id *oid,
+                                    const char *path,
+                                    int stage,
+                                    unsigned int refresh_options)
 {
        int size, len;
        struct cache_entry *ce, *ret;
@@ -761,7 +763,7 @@ struct cache_entry *make_cache_entry(unsigned int mode,
        size = cache_entry_size(len);
        ce = xcalloc(1, size);
 
-       hashcpy(ce->oid.hash, sha1);
+       oidcpy(&ce->oid, oid);
        memcpy(ce->name, path, len);
        ce->ce_flags = create_ce_flags(stage);
        ce->ce_namelen = len;
index fc5b3b83d9a08e9deed55ee15520387f147da626..4d4e5cb6bf9c48aa66ec70eee780d2455563d099 100644 (file)
@@ -146,7 +146,7 @@ int unmerge_index_entry_at(struct index_state *istate, int pos)
                struct cache_entry *nce;
                if (!ru->mode[i])
                        continue;
-               nce = make_cache_entry(ru->mode[i], ru->oid[i].hash,
+               nce = make_cache_entry(ru->mode[i], &ru->oid[i],
                                       name, i + 1, 0);
                if (matched)
                        nce->ce_flags |= CE_MATCHED;