repository:new config to only check files matched sparse-checkout patterns.
PATCH 1/1 repository:new config to only check files matched sparse-checkout patterns.
From: Canwei He <[email protected]>
By Default with sparse checkouts, all files with SKIP_WORKTREE bit in the index must check whether exists in the worktree. And Git will expand all of that files in the index and must traverse recursively in the worktree. This option can be used to tell Git that just check files which can match the sparse-checkout patterns.
It is useful when you are using a visual file system in order to on-demand loading working tree lazily. It can control which directory should load by using sparse-checkout patterns. But it doesn't want to visit other directory which haven't been load but just have an empty directory for the entry of the file loading switch. In default model, Git would traverse root direcotry recursively however all files would be loaded, this behaviour would very expensive. With sparse.onlyCheckFilesMatchPatterns model, Git would just check the path witch only matched the sparse-checkout patterns to prevent loading all the directory.
---
repository:new config to only check files matched sparse-checkout patterns.
repository:new config to only check files matched sparse-checkout patterns.
By Default with sparse checkouts, all files with SKIP_WORKTREE bit in the index must check whether exists in the worktree. And Git will expand all of that files in the index and must traverse recursively in the worktree. This option can be used to tell Git that just check files which can match the sparse-checkout patterns.
It is useful when you are using a visual file system in order to on-demand loading working tree lazily. It can control which directory should load by using sparse-checkout patterns. But it doesn't want to visit other directory which haven't been load but just have an empty directory for the entry of the file loading switch. In default model, Git would traverse root direcotry recursively however all files would be loaded, this behaviour would very expensive. With sparse.onlyCheckFilesMatchPatterns model, Git would just check the path witch only matched the sparse-checkout patterns to prevent loading all the directory.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1295%2FfvoidCN%2Fvoidhe-upstream-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1295/fvoidCN/voidhe-upstream-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1295
Documentation/config/sparse.txt | 25 ++++++++++++++++ cache.h | 1 + config.c | 5 ++++ environment.c | 1 + sparse-index.c | 19 ++++++++---- t/t1090-sparse-checkout-scope.sh | 50 ++++++++++++++++++++++++++++++++ 6 files changed, 95 insertions(+), 6 deletions(-)
Documentation/config/sparse.txt +25 -0
@@ -25,3 +25,28 @@ Regardless of this setting, Git does not check for present-despite-skipped files unless sparse checkout is enabled, so this config option has no effect unless `core.sparseCheckout` is `true`. + +sparse.onlyCheckFilesMatchPatterns:: + By Default with sparse checkouts, all files with SKIP_WORKTREE bit + in the index must check whether exists in the worktree. And Git will + expand all of that files in the index and must traverse recursively + in the worktree. This option can be used to tell Git that just check + files which can match the sparse-checkout patterns. ++ +The default is `false`, which allows Git to automatically recover +from the list of files in the index and working tree falling out of +sync. ++ +Set this to `true` if you just hope Git maintain the consistency +between the presence of working tree files and sparsity patterns +confining to which match the sparse-checkout patterns.For example, +if you are using a visual file system in order to on-demand loading +working tree lazily. It can control which directory should load by +using sparse-checkout patterns. But it doesn't want to visit other +directory which haven't been load but just have an empty directory +for the entry of the file loading switch. ++ +Regardless of this setting, Git does not check for +present-despite-skipped files unless sparse checkout is enabled, so +this config option has no effect unless `core.sparseCheckout` is +`true`.
cache.h +1 -0
@@ -1074,6 +1074,7 @@ extern int protect_ntfs;extern int core_apply_sparse_checkout;extern int core_sparse_checkout_cone;extern int sparse_expect_files_outside_of_patterns; +extern int sparse_only_check_files_match_patterns;/* * Returns the boolean value of $GIT_OPTIONAL_LOCKS (or the default value).
config.c +5 -0
@@ -1758,6 +1758,11 @@ static int git_default_sparse_config(const char *var, const char *value)return 0 ; } +if (!strcmp (var,"sparse.onlycheckfilesmatchpatterns" )) { + sparse_only_check_files_match_patterns =git_config_bool (var, value); +return 0 ; + } +/* Add other config variables here and to Documentation/config/sparse.txt. */ return 0 ; }
environment.c +1 -0
@@ -73,6 +73,7 @@ int grafts_replace_parents = 1;int core_apply_sparse_checkout;int core_sparse_checkout_cone;int sparse_expect_files_outside_of_patterns; +int sparse_only_check_files_match_patterns;int merge_log_config =-1 ;int precomposed_unicode =-1 ;/* see probe_utf8_pathname_composition() */ unsigned long pack_size_limit_cfg;
sparse-index.c +13 -6
@@ -502,14 +502,21 @@ restart:for (i =0 ; i < istate->cache_nr; i++) {struct cache_entry *ce = istate->cache[i]; -if (ce_skip_worktree (ce) && -path_found (ce->name, &last_dirname, &dir_len, &dir_found)) { -if (S_ISSPARSEDIR (ce->ce_mode)) { -ensure_full_index (istate); - goto restart; +if (ce_skip_worktree (ce)) { +if (sparse_only_check_files_match_patterns && + !path_in_sparse_checkout (ce->name, istate)){ +continue ; + } + +if (path_found (ce->name, &last_dirname, &dir_len, &dir_found)) { +if (S_ISSPARSEDIR (ce->ce_mode)) { +ensure_full_index (istate); + goto restart; + } + ce->ce_flags &= ~CE_SKIP_WORKTREE ; } - ce->ce_flags &= ~CE_SKIP_WORKTREE ; } + } }
t/t1090-sparse-checkout-scope.sh +50 -0
56 lines not on this page · raw message
base-commit: 9dd64cb4d310986dd7b8ca7fff92f9b61e0bd21a
Signature · 1 line
gitgitgadget