entry.c: update cache_changed if refresh_cache is set in checkout_entry()

Other fill_stat_cache_info() is on new entries, which should set CE_ENTRY_ADDED in cache_changed, so we're safe. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Jun 13, 2014 at 19:19 UTC d4a2024aef90fa5dd2b0e5027f9340719ff20748
6 files changed +11 -3
builtin/apply.c
+5 -3
@@ -3084,13 +3084,15 @@ static void prepare_fn_table(struct patch *patch)
3084 }
3085 }
3086
3087 -static int checkout_target(struct cache_entry *ce, struct stat *st)
3087 +static int checkout_target(struct index_state *istate,
3088 + struct cache_entry *ce, struct stat *st)
3089 {
3090 struct checkout costate;
3091
3092 memset(&costate, 0, sizeof(costate));
3093 costate.base_dir = "";
3094 costate.refresh_cache = 1;
3095 + costate.istate = istate;
3096 if (checkout_entry(ce, &costate, NULL) || lstat(ce->name, st))
3097 return error(_("cannot checkout %s"), ce->name);
3098 return 0;
@@ -3257,7 +3259,7 @@ static int load_current(struct image *image, struct patch *patch)
3259 if (lstat(name, &st)) {
3260 if (errno != ENOENT)
3261 return error(_("%s: %s"), name, strerror(errno));
3260 - if (checkout_target(ce, &st))
3262 + if (checkout_target(&the_index, ce, &st))
3263 return -1;
3264 }
3265 if (verify_index_match(ce, &st))
@@ -3411,7 +3413,7 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
3413 }
3414 *ce = active_cache[pos];
3415 if (stat_ret < 0) {
3414 - if (checkout_target(*ce, st))
3416 + if (checkout_target(&the_index, *ce, st))
3417 return -1;
3418 }
3419 if (!cached && verify_index_match(*ce, st))
builtin/checkout-index.c
+1
@@ -135,6 +135,7 @@ static int option_parse_u(const struct option *opt,
135 int *newfd = opt->value;
136
137 state.refresh_cache = 1;
138 + state.istate = &the_index;
139 if (*newfd < 0)
140 *newfd = hold_locked_index(&lock_file, 1);
141 return 0;
builtin/checkout.c
+1
@@ -336,6 +336,7 @@ static int checkout_paths(const struct checkout_opts *opts,
336 memset(&state, 0, sizeof(state));
337 state.force = 1;
338 state.refresh_cache = 1;
339 + state.istate = &the_index;
340 for (pos = 0; pos < active_nr; pos++) {
341 struct cache_entry *ce = active_cache[pos];
342 if (ce->ce_flags & CE_MATCHED) {
cache.h
+1
@@ -1063,6 +1063,7 @@ extern int split_ident_line(struct ident_split *, const char *, int);
1063 extern int ident_cmp(const struct ident_split *, const struct ident_split *);
1064
1065 struct checkout {
1066 + struct index_state *istate;
1067 const char *base_dir;
1068 int base_dir_len;
1069 unsigned force:1,
entry.c
+2
@@ -210,9 +210,11 @@ static int write_entry(struct cache_entry *ce,
210
211 finish:
212 if (state->refresh_cache) {
213 + assert(state->istate);
214 if (!fstat_done)
215 lstat(ce->name, &st);
216 fill_stat_cache_info(ce, &st);
217 + state->istate->cache_changed |= CE_ENTRY_CHANGED;
218 }
219 return 0;
220 }
unpack-trees.c
+1
@@ -1029,6 +1029,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
1029 state.force = 1;
1030 state.quiet = 1;
1031 state.refresh_cache = 1;
1032 + state.istate = &o->result;
1033
1034 memset(&el, 0, sizeof(el));
1035 if (!core_apply_sparse_checkout || !o->update)