sparse-index.c: remove set_index_sparse_config()

Remove the set_index_sparse_config() function by folding it into set_sparse_index_config(), which was its only user. Since 122ba1f7b52 (sparse-checkout: toggle sparse index from builtin, 2021-03-30) the flow of this code hasn't made much sense, we'd get "enabled" in set_sparse_index_config(), proceed to call set_index_sparse_config() with it. There we'd call prepare_repo_settings() and set "repo->settings.sparse_index = 1", only to needlessly call prepare_repo_settings() again in set_sparse_index_config() (where it would early abort), and finally setting "repo->settings.sparse_index = enabled". Instead we can just call prepare_repo_settings() once, and set the variable to "enabled" in the first place. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed May 5, 2021 at 14:11 UTC b79f9c075d4cb61bd7d030e9589ad50ec9e83a60
1 file changed +1 -10
sparse-index.c
+1 -10
@@ -102,7 +102,7 @@ static int convert_to_sparse_rec(struct index_state *istate,
102 return num_converted - start_converted;
103 }
104
105 -static int set_index_sparse_config(struct repository *repo, int enable)
105 +int set_sparse_index_config(struct repository *repo, int enable)
106 {
107 int res;
108 char *config_path = repo_git_path(repo, "config.worktree");
@@ -111,15 +111,6 @@ static int set_index_sparse_config(struct repository *repo, int enable)
111 enable ? "true" : NULL);
112 free(config_path);
113
114 - prepare_repo_settings(repo);
115 - repo->settings.sparse_index = 1;
116 - return res;
117 -}
118 -
119 -int set_sparse_index_config(struct repository *repo, int enable)
120 -{
121 - int res = set_index_sparse_config(repo, enable);
122 -
114 prepare_repo_settings(repo);
115 repo->settings.sparse_index = enable;
116 return res;