Skip to content

Commit b6b4a96

Browse files
committed
sparse-index: declare command_requires_full_index for undeclared commands
These four code paths were found to never declare their command_requires_full_index value. Set them to 1 (require full index expansion) as a safe default, with comments noting they have not yet been verified for sparse-index compatibility. Found by changing the default to -1 (unset) and adding an accessor that dies when a command reads the index without first declaring its sparse-index requirement.
1 parent 3585a31 commit b6b4a96

4 files changed

Lines changed: 19 additions & 0 deletions

File tree

builtin/am.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "lockfile.h"
2424
#include "cache-tree.h"
2525
#include "refs.h"
26+
#include "repo-settings.h"
2627
#include "commit.h"
2728
#include "diff.h"
2829
#include "unpack-trees.h"
@@ -2464,6 +2465,10 @@ int cmd_am(int argc,
24642465
/* Ensure a valid committer ident can be constructed */
24652466
git_committer_info(IDENT_STRICT);
24662467

2468+
/* not yet verified whether this can use the sparse index */
2469+
prepare_repo_settings(the_repository);
2470+
the_repository->settings.command_requires_full_index = 1;
2471+
24672472
if (repo_read_index_preload(the_repository, NULL, 0) < 0)
24682473
die(_("failed to read the index"));
24692474

builtin/grep.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,10 @@ static int grep_submodule(struct grep_opt *opt,
500500
*
501501
* Note that this list is not exhaustive.
502502
*/
503+
/* not yet verified whether subrepo can use the sparse index */
504+
prepare_repo_settings(subrepo);
505+
subrepo->settings.command_requires_full_index = 1;
506+
503507
repo_read_gitmodules(subrepo, 0);
504508

505509
/*

builtin/mv.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "string-list.h"
2323
#include "parse-options.h"
2424
#include "read-cache-ll.h"
25+
#include "repo-settings.h"
2526

2627
#include "setup.h"
2728
#include "strvec.h"
@@ -247,6 +248,10 @@ int cmd_mv(int argc,
247248
if (--argc < 1)
248249
usage_with_options(builtin_mv_usage, builtin_mv_options);
249250

251+
/* not yet verified whether this can use the sparse index */
252+
prepare_repo_settings(the_repository);
253+
the_repository->settings.command_requires_full_index = 1;
254+
250255
repo_hold_locked_index(the_repository, &lock_file, LOCK_DIE_ON_ERROR);
251256
if (repo_read_index(the_repository) < 0)
252257
die(_("index file corrupt"));

builtin/submodule--helper.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "read-cache.h"
1717
#include "setup.h"
1818
#include "sparse-index.h"
19+
#include "repo-settings.h"
1920
#include "submodule.h"
2021
#include "submodule-config.h"
2122
#include "string-list.h"
@@ -3832,5 +3833,9 @@ int cmd_submodule__helper(int argc,
38323833
};
38333834
argc = parse_options(argc, argv, prefix, options, usage, 0);
38343835

3836+
/* not yet verified whether this can use the sparse index */
3837+
prepare_repo_settings(the_repository);
3838+
the_repository->settings.command_requires_full_index = 1;
3839+
38353840
return fn(argc, argv, prefix, repo);
38363841
}

0 commit comments

Comments
 (0)