
When sparse checkout is enabled, some users expect the output of certain commands (such as grep, diff, and log) to be also restricted within the sparsity patterns. This would allow them to effectively work only on the subset of files in which they are interested; and allow some commands to possibly perform better, by not considering uninteresting paths. For this reason, we taught grep to honor the sparsity patterns, in the previous patch. But, on the other hand, allowing grep and the other commands mentioned to optionally ignore the patterns also make for some interesting use cases. E.g. using grep to search for a function documentation that resides outside the sparse checkout. In any case, there is no current way for users to configure the behavior they want for these commands. Aiming to provide this flexibility, let's introduce the sparse.restrictCmds setting (and the analogous --[no]-restrict-to-sparse-paths global option). The default value is true. For now, grep is the only one affected by this setting, but the goal is to have support for more commands, in the future. Helped-by: Elijah Newren <newren@gmail.com> Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br> Signed-off-by: Junio C Hamano <gitster@pobox.com>
19 lines
345 B
C
19 lines
345 B
C
#include "cache.h"
|
|
#include "config.h"
|
|
#include "sparse-checkout.h"
|
|
|
|
int opt_restrict_to_sparse_paths = -1;
|
|
|
|
int restrict_to_sparse_paths(struct repository *repo)
|
|
{
|
|
int ret;
|
|
|
|
if (opt_restrict_to_sparse_paths >= 0)
|
|
return opt_restrict_to_sparse_paths;
|
|
|
|
if (repo_config_get_bool(repo, "sparse.restrictcmds", &ret))
|
|
ret = 1;
|
|
|
|
return ret;
|
|
}
|