| 416 | } |
| 417 | |
| 418 | static int update_modes(struct repository *repo, int *cone_mode, int *sparse_index) |
| 419 | { |
| 420 | int mode, record_mode; |
| 421 | struct repo_config_values *cfg = repo_config_values(the_repository); |
| 422 | |
| 423 | /* Determine if we need to record the mode; ensure sparse checkout on */ |
| 424 | record_mode = (*cone_mode != -1) || !cfg->apply_sparse_checkout; |
| 425 | |
| 426 | mode = update_cone_mode(cone_mode); |
| 427 | if (record_mode && set_config(repo, mode)) |
| 428 | return 1; |
| 429 | |
| 430 | /* Set sparse-index/non-sparse-index mode if specified */ |
| 431 | if (*sparse_index >= 0) { |
| 432 | if (set_sparse_index_config(repo, *sparse_index) < 0) |
| 433 | die(_("failed to modify sparse-index config")); |
| 434 | |
| 435 | /* force an index rewrite */ |
| 436 | repo_read_index(repo); |
| 437 | repo->index->updated_workdir = 1; |
| 438 | |
| 439 | if (!*sparse_index) |
| 440 | ensure_full_index(repo->index); |
| 441 | } |
| 442 | |
| 443 | return 0; |
| 444 | } |
| 445 | |
| 446 | static char const * const builtin_sparse_checkout_init_usage[] = { |
| 447 | "git sparse-checkout init [--cone] [--[no-]sparse-index]", |
no test coverage detected