Skip to content

Commit d4a2024

Browse files
pcloudsgitster
authored andcommitted
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>
1 parent e6c286e commit d4a2024

File tree

6 files changed

+11
-3
lines changed

6 files changed

+11
-3
lines changed

builtin/apply.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3084,13 +3084,15 @@ static void prepare_fn_table(struct patch *patch)
30843084
}
30853085
}
30863086

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)
30883089
{
30893090
struct checkout costate;
30903091

30913092
memset(&costate, 0, sizeof(costate));
30923093
costate.base_dir = "";
30933094
costate.refresh_cache = 1;
3095+
costate.istate = istate;
30943096
if (checkout_entry(ce, &costate, NULL) || lstat(ce->name, st))
30953097
return error(_("cannot checkout %s"), ce->name);
30963098
return 0;
@@ -3257,7 +3259,7 @@ static int load_current(struct image *image, struct patch *patch)
32573259
if (lstat(name, &st)) {
32583260
if (errno != ENOENT)
32593261
return error(_("%s: %s"), name, strerror(errno));
3260-
if (checkout_target(ce, &st))
3262+
if (checkout_target(&the_index, ce, &st))
32613263
return -1;
32623264
}
32633265
if (verify_index_match(ce, &st))
@@ -3411,7 +3413,7 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
34113413
}
34123414
*ce = active_cache[pos];
34133415
if (stat_ret < 0) {
3414-
if (checkout_target(*ce, st))
3416+
if (checkout_target(&the_index, *ce, st))
34153417
return -1;
34163418
}
34173419
if (!cached && verify_index_match(*ce, st))

builtin/checkout-index.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ static int option_parse_u(const struct option *opt,
135135
int *newfd = opt->value;
136136

137137
state.refresh_cache = 1;
138+
state.istate = &the_index;
138139
if (*newfd < 0)
139140
*newfd = hold_locked_index(&lock_file, 1);
140141
return 0;

builtin/checkout.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ static int checkout_paths(const struct checkout_opts *opts,
336336
memset(&state, 0, sizeof(state));
337337
state.force = 1;
338338
state.refresh_cache = 1;
339+
state.istate = &the_index;
339340
for (pos = 0; pos < active_nr; pos++) {
340341
struct cache_entry *ce = active_cache[pos];
341342
if (ce->ce_flags & CE_MATCHED) {

cache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,7 @@ extern int split_ident_line(struct ident_split *, const char *, int);
10631063
extern int ident_cmp(const struct ident_split *, const struct ident_split *);
10641064

10651065
struct checkout {
1066+
struct index_state *istate;
10661067
const char *base_dir;
10671068
int base_dir_len;
10681069
unsigned force:1,

entry.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,11 @@ static int write_entry(struct cache_entry *ce,
210210

211211
finish:
212212
if (state->refresh_cache) {
213+
assert(state->istate);
213214
if (!fstat_done)
214215
lstat(ce->name, &st);
215216
fill_stat_cache_info(ce, &st);
217+
state->istate->cache_changed |= CE_ENTRY_CHANGED;
216218
}
217219
return 0;
218220
}

unpack-trees.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
10291029
state.force = 1;
10301030
state.quiet = 1;
10311031
state.refresh_cache = 1;
1032+
state.istate = &o->result;
10321033

10331034
memset(&el, 0, sizeof(el));
10341035
if (!core_apply_sparse_checkout || !o->update)

0 commit comments

Comments
 (0)