Skip to content

Commit 74cfc0e

Browse files
pcloudsgitster
authored andcommitted
entry.c: use the right index instead of the_index
checkout-index.c needs update because if checkout->istate is NULL, ie_match_stat() will crash. Previously this is ie_match_stat(&the_index, ..) so it will not crash, but it is not technically correct either. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 68f08b4 commit 74cfc0e

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

builtin/checkout-index.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
190190

191191
argc = parse_options(argc, argv, prefix, builtin_checkout_index_options,
192192
builtin_checkout_index_usage, 0);
193+
state.istate = &the_index;
193194
state.force = force;
194195
state.quiet = quiet;
195196
state.not_new = not_new;

entry.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ static int write_entry(struct cache_entry *ce,
266266
const struct submodule *sub;
267267

268268
if (ce_mode_s_ifmt == S_IFREG) {
269-
struct stream_filter *filter = get_stream_filter(&the_index, ce->name,
269+
struct stream_filter *filter = get_stream_filter(state->istate, ce->name,
270270
&ce->oid);
271271
if (filter &&
272272
!streaming_write_entry(ce, path, filter,
@@ -314,14 +314,14 @@ static int write_entry(struct cache_entry *ce,
314314
* Convert from git internal format to working tree format
315315
*/
316316
if (dco && dco->state != CE_NO_DELAY) {
317-
ret = async_convert_to_working_tree(&the_index, ce->name, new_blob,
317+
ret = async_convert_to_working_tree(state->istate, ce->name, new_blob,
318318
size, &buf, dco);
319319
if (ret && string_list_has_string(&dco->paths, ce->name)) {
320320
free(new_blob);
321321
goto delayed;
322322
}
323323
} else
324-
ret = convert_to_working_tree(&the_index, ce->name, new_blob, size, &buf);
324+
ret = convert_to_working_tree(state->istate, ce->name, new_blob, size, &buf);
325325

326326
if (ret) {
327327
free(new_blob);
@@ -422,7 +422,8 @@ int checkout_entry(struct cache_entry *ce,
422422

423423
if (!check_path(path.buf, path.len, &st, state->base_dir_len)) {
424424
const struct submodule *sub;
425-
unsigned changed = ce_match_stat(ce, &st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE);
425+
unsigned changed = ie_match_stat(state->istate, ce, &st,
426+
CE_MATCH_IGNORE_VALID | CE_MATCH_IGNORE_SKIP_WORKTREE);
426427
/*
427428
* Needs to be checked before !changed returns early,
428429
* as the possibly empty directory was not changed

0 commit comments

Comments
 (0)