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>
Nguyễn Thái Ngọc Duy committed
Aug 13, 2018 at 18:14 UTC
74cfc0ee1d0b4e386b5a07f8b79fbcece94cdff8
2 files changed
+6
-4
builtin/checkout-index.c
+1
@@ -190,6 +190,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
190
191
argc = parse_options(argc, argv, prefix, builtin_checkout_index_options,
192
builtin_checkout_index_usage, 0);
193
+ state.istate = &the_index;
194
state.force = force;
195
state.quiet = quiet;
196
state.not_new = not_new;
entry.c
+5
-4
@@ -266,7 +266,7 @@ static int write_entry(struct cache_entry *ce,
266
const struct submodule *sub;
267
268
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,
270
&ce->oid);
271
if (filter &&
272
!streaming_write_entry(ce, path, filter,
@@ -314,14 +314,14 @@ static int write_entry(struct cache_entry *ce,
314
* Convert from git internal format to working tree format
315
*/
316
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,
318
size, &buf, dco);
319
if (ret && string_list_has_string(&dco->paths, ce->name)) {
320
free(new_blob);
321
goto delayed;
322
}
323
} 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);
325
326
if (ret) {
327
free(new_blob);
@@ -422,7 +422,8 @@ int checkout_entry(struct cache_entry *ce,
422
423
if (!check_path(path.buf, path.len, &st, state->base_dir_len)) {
424
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);
427
/*
428
* Needs to be checked before !changed returns early,
429
* as the possibly empty directory was not changed