Skip to content

Commit 825ed4d

Browse files
jamillgitster
authored andcommitted
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 <[email protected]>
1 parent 768d796 commit 825ed4d

File tree

8 files changed

+18
-11
lines changed

8 files changed

+18
-11
lines changed

apply.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4090,7 +4090,7 @@ static int build_fake_ancestor(struct apply_state *state, struct patch *list)
40904090
return error(_("sha1 information is lacking or useless "
40914091
"(%s)."), name);
40924092

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);
40944094
if (!ce)
40954095
return error(_("make_cache_entry failed for path '%s'"),
40964096
name);

builtin/checkout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ static int checkout_merged(int pos, const struct checkout *state)
230230
if (write_object_file(result_buf.ptr, result_buf.size, blob_type, &oid))
231231
die(_("Unable to add merge result for '%s'"), path);
232232
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);
234234
if (!ce)
235235
die(_("make_cache_entry failed for path '%s'"), path);
236236
status = checkout_entry(ce, state, NULL);

builtin/difftool.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ static int checkout_path(unsigned mode, struct object_id *oid,
321321
struct cache_entry *ce;
322322
int ret;
323323

324-
ce = make_cache_entry(mode, oid->hash, path, 0, 0);
324+
ce = make_cache_entry(mode, oid, path, 0, 0);
325325
ret = checkout_entry(ce, state, NULL);
326326

327327
free(ce);
@@ -488,7 +488,7 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
488488
* index.
489489
*/
490490
struct cache_entry *ce2 =
491-
make_cache_entry(rmode, roid.hash,
491+
make_cache_entry(rmode, &roid,
492492
dst_path, 0, 0);
493493

494494
add_index_entry(&wtindex, ce2,

builtin/reset.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ static void update_index_from_diff(struct diff_queue_struct *q,
134134
continue;
135135
}
136136

137-
ce = make_cache_entry(one->mode, one->oid.hash, one->path,
137+
ce = make_cache_entry(one->mode, &one->oid, one->path,
138138
0, 0);
139139
if (!ce)
140140
die(_("make_cache_entry failed for path '%s'"),

cache.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,12 @@ extern int remove_file_from_index(struct index_state *, const char *path);
698698
extern int add_to_index(struct index_state *, const char *path, struct stat *, int flags);
699699
extern int add_file_to_index(struct index_state *, const char *path, int flags);
700700

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+
702707
extern int chmod_index_entry(struct index_state *, struct cache_entry *ce, char flip);
703708
extern int ce_same_name(const struct cache_entry *a, const struct cache_entry *b);
704709
extern void set_object_name_for_intent_to_add_entry(struct cache_entry *ce);

merge-recursive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ static int add_cacheinfo(struct merge_options *o,
315315
struct cache_entry *ce;
316316
int ret;
317317

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);
319319
if (!ce)
320320
return err(o, _("add_cacheinfo failed for path '%s'; merge aborting."), path);
321321

read-cache.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,10 @@ int add_file_to_index(struct index_state *istate, const char *path, int flags)
746746
}
747747

748748
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)
751753
{
752754
int size, len;
753755
struct cache_entry *ce, *ret;
@@ -761,7 +763,7 @@ struct cache_entry *make_cache_entry(unsigned int mode,
761763
size = cache_entry_size(len);
762764
ce = xcalloc(1, size);
763765

764-
hashcpy(ce->oid.hash, sha1);
766+
oidcpy(&ce->oid, oid);
765767
memcpy(ce->name, path, len);
766768
ce->ce_flags = create_ce_flags(stage);
767769
ce->ce_namelen = len;

resolve-undo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ int unmerge_index_entry_at(struct index_state *istate, int pos)
146146
struct cache_entry *nce;
147147
if (!ru->mode[i])
148148
continue;
149-
nce = make_cache_entry(ru->mode[i], ru->oid[i].hash,
149+
nce = make_cache_entry(ru->mode[i], &ru->oid[i],
150150
name, i + 1, 0);
151151
if (matched)
152152
nce->ce_flags |= CE_MATCHED;

0 commit comments

Comments
 (0)