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>
This commit is contained in:
parent
768d796506
commit
825ed4d9a0
2
apply.c
2
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);
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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'"),
|
||||
|
7
cache.h
7
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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user