Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatheus Tavares <matheus.bernardino@usp.br>2021-02-10 00:33:30 +0300
committerJunio C Hamano <gitster@pobox.com>2021-02-10 10:10:51 +0300
commit42d906bec48c95d66cb669ee41ce04330f74a98b (patch)
tree8b2006eeeaaab7b380b94cae9be9cde2e7619277 /t/t7011-skip-worktree-reading.sh
parent773e25afc41b1b6533fa9ae2cd825d0b4a697fad (diff)
grep: honor sparse-checkout on working tree searches
On a sparse checked out repository, `git grep` (without --cached) ends up searching the cache when an entry matches the search pathspec and has the SKIP_WORKTREE bit set. This is confusing both because the sparse paths are not expected to be in a working tree search (as they are not checked out), and because the output mixes working tree and cache results without distinguishing them. (Note that grep also resorts to the cache on working tree searches that include --assume-unchanged paths. But the whole point in that case is to assume that the contents of the index entry and the file are the same. This does not apply to the case of sparse paths, where the file isn't even expected to be present.) Fix that by teaching grep to honor the sparse-checkout rules for working tree searches. If the user wants to grep paths outside the current sparse-checkout definition, they may either update the sparsity rules to materialize the files, or use --cached to search all blobs registered in the index. Note: it might also be interesting to add a configuration option that allow users to search paths that are present despite having the SKIP_WORKTREE bit set, and/or to restrict searches in the index and past revisions too. These ideas are left as future improvements to avoid conflicting with other sparse-checkout topics currently in flight. Suggested-by: Elijah Newren <newren@gmail.com> Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br> Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7011-skip-worktree-reading.sh')
-rwxr-xr-xt/t7011-skip-worktree-reading.sh9
1 files changed, 0 insertions, 9 deletions
diff --git a/t/t7011-skip-worktree-reading.sh b/t/t7011-skip-worktree-reading.sh
index 37525cae3a..26852586ac 100755
--- a/t/t7011-skip-worktree-reading.sh
+++ b/t/t7011-skip-worktree-reading.sh
@@ -109,15 +109,6 @@ test_expect_success 'ls-files --modified' '
test -z "$(git ls-files -m)"
'
-test_expect_success 'grep with skip-worktree file' '
- git update-index --no-skip-worktree 1 &&
- echo test > 1 &&
- git update-index 1 &&
- git update-index --skip-worktree 1 &&
- rm 1 &&
- test "$(git grep --no-ext-grep test)" = "1:test"
-'
-
echo ":000000 100644 $ZERO_OID $EMPTY_BLOB A 1" > expected
test_expect_success 'diff-index does not examine skip-worktree absent entries' '
setup_absent &&