read-cache: teach make_cache_entry to take object_id
Teach make_cache_entry function to take object_id instead of a SHA-1. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jameson Miller committed
Jul 2, 2018 at 19:49 UTC
825ed4d9a044380ac093563e6bd74311ea4488ef
8 files changed
+18
-11
apply.c
+1
-1
@@ -4090,7 +4090,7 @@ static int build_fake_ancestor(struct apply_state *state, struct patch *list)
4090
return error(_("sha1 information is lacking or useless "
4091
"(%s)."), name);
4092
4093
- ce = make_cache_entry(patch->old_mode, oid.hash, name, 0, 0);
4093
+ ce = make_cache_entry(patch->old_mode, &oid, name, 0, 0);
4094
if (!ce)
4095
return error(_("make_cache_entry failed for path '%s'"),
4096
name);
builtin/checkout.c
+1
-1
@@ -230,7 +230,7 @@ static int checkout_merged(int pos, const struct checkout *state)
230
if (write_object_file(result_buf.ptr, result_buf.size, blob_type, &oid))
231
die(_("Unable to add merge result for '%s'"), path);
232
free(result_buf.ptr);
233
- ce = make_cache_entry(mode, oid.hash, path, 2, 0);
233
+ ce = make_cache_entry(mode, &oid, path, 2, 0);
234
if (!ce)
235
die(_("make_cache_entry failed for path '%s'"), path);
236
status = checkout_entry(ce, state, NULL);
builtin/difftool.c
+2
-2
@@ -321,7 +321,7 @@ static int checkout_path(unsigned mode, struct object_id *oid,
321
struct cache_entry *ce;
322
int ret;
323
324
- ce = make_cache_entry(mode, oid->hash, path, 0, 0);
324
+ ce = make_cache_entry(mode, oid, path, 0, 0);
325
ret = checkout_entry(ce, state, NULL);
326
327
free(ce);
@@ -488,7 +488,7 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
488
* index.
489
*/
490
struct cache_entry *ce2 =
491
- make_cache_entry(rmode, roid.hash,
491
+ make_cache_entry(rmode, &roid,
492
dst_path, 0, 0);
493
494
add_index_entry(&wtindex, ce2,
builtin/reset.c
+1
-1
@@ -134,7 +134,7 @@ static void update_index_from_diff(struct diff_queue_struct *q,
134
continue;
135
}
136
137
- ce = make_cache_entry(one->mode, one->oid.hash, one->path,
137
+ ce = make_cache_entry(one->mode, &one->oid, one->path,
138
0, 0);
139
if (!ce)
140
die(_("make_cache_entry failed for path '%s'"),
cache.h
+6
-1
@@ -698,7 +698,12 @@ extern int remove_file_from_index(struct index_state *, const char *path);
698
extern int add_to_index(struct index_state *, const char *path, struct stat *, int flags);
699
extern int add_file_to_index(struct index_state *, const char *path, int flags);
700
701
-extern struct cache_entry *make_cache_entry(unsigned int mode, const unsigned char *sha1, const char *path, int stage, unsigned int refresh_options);
701
+extern struct cache_entry *make_cache_entry(unsigned int mode,
702
+ const struct object_id *oid,
703
+ const char *path,
704
+ int stage,
705
+ unsigned int refresh_options);
706
+
707
extern int chmod_index_entry(struct index_state *, struct cache_entry *ce, char flip);
708
extern int ce_same_name(const struct cache_entry *a, const struct cache_entry *b);
709
extern void set_object_name_for_intent_to_add_entry(struct cache_entry *ce);
merge-recursive.c
+1
-1
@@ -315,7 +315,7 @@ static int add_cacheinfo(struct merge_options *o,
315
struct cache_entry *ce;
316
int ret;
317
318
- ce = make_cache_entry(mode, oid ? oid->hash : null_sha1, path, stage, 0);
318
+ ce = make_cache_entry(mode, oid ? oid : &null_oid, path, stage, 0);
319
if (!ce)
320
return err(o, _("add_cacheinfo failed for path '%s'; merge aborting."), path);
321
read-cache.c
+5
-3
@@ -746,8 +746,10 @@ int add_file_to_index(struct index_state *istate, const char *path, int flags)
746
}
747
748
struct cache_entry *make_cache_entry(unsigned int mode,
749
- const unsigned char *sha1, const char *path, int stage,
750
- unsigned int refresh_options)
749
+ const struct object_id *oid,
750
+ const char *path,
751
+ int stage,
752
+ unsigned int refresh_options)
753
{
754
int size, len;
755
struct cache_entry *ce, *ret;
@@ -761,7 +763,7 @@ struct cache_entry *make_cache_entry(unsigned int mode,
763
size = cache_entry_size(len);
764
ce = xcalloc(1, size);
765
764
- hashcpy(ce->oid.hash, sha1);
766
+ oidcpy(&ce->oid, oid);
767
memcpy(ce->name, path, len);
768
ce->ce_flags = create_ce_flags(stage);
769
ce->ce_namelen = len;
resolve-undo.c
+1
-1
@@ -146,7 +146,7 @@ int unmerge_index_entry_at(struct index_state *istate, int pos)
146
struct cache_entry *nce;
147
if (!ru->mode[i])
148
continue;
149
- nce = make_cache_entry(ru->mode[i], ru->oid[i].hash,
149
+ nce = make_cache_entry(ru->mode[i], &ru->oid[i],
150
name, i + 1, 0);
151
if (matched)
152
nce->ce_flags |= CE_MATCHED;