forked from git-for-windows/git
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gvfs: use a hashmap to back gitignore/sparse checkout
The always_exclude mechanism is used both to implement the excludes defined in, say, .gitignore, and the sparse checkout feature. Due to its use of wildcards, any sizable list of entries will slow down every path-related operation dramatically. This is particularly noticeable with GVFS, where the sparse-checkout file is populated and updated frequently by the backend. In GVFS' case, the use of wildcards is limited to same-directory wildcards (i.e. something of the form `/this/directory/*`), though, therefore we can speed up everything dramatically by using exact matches backed by a hashmap. Note: the use of a hashmap disallows more free-form sparse-checkout entries such as `*.txt`. Using a hashmap restricts us to only allow exact file names, same-directory, and negative entries in the sparse-checkout file, but with GVFS that is all we need. This patch introduces the option to make it so. Signed-off-by: Eric Mecklenburg <ermeckle@microsoft.com>
- Loading branch information
Showing
5 changed files
with
240 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
#!/bin/sh | ||
|
||
test_description='always_exclude hashmap tests' | ||
|
||
. ./test-lib.sh | ||
|
||
test_expect_success 'setup' ' | ||
mkdir -p dir1/dir2 && | ||
>a && | ||
>dir1/a && | ||
>dir1/b && | ||
>dir1/dir2/a && | ||
cat >.gitignore <<\EOF | ||
standard | ||
with_hashmap | ||
EOF | ||
' | ||
|
||
test_expect_success 'status with positive simple exact match' ' | ||
cat >.git/info/always_exclude <<\EOF && | ||
a | ||
EOF | ||
git status -u >standard && | ||
git config --local core.gvfs 512 && | ||
git status -u >with_hashmap && | ||
git config --local core.gvfs 0 && | ||
test_cmp standard with_hashmap | ||
' | ||
|
||
test_expect_success 'status with negative simple exact match' ' | ||
cat >.git/info/always_exclude <<\EOF && | ||
!a | ||
EOF | ||
git status -u >standard && | ||
git config --local core.gvfs 512 && | ||
git status -u >with_hashmap && | ||
git config --local core.gvfs 0 && | ||
test_cmp standard with_hashmap | ||
' | ||
|
||
test_expect_success 'status with matching exact match' ' | ||
cat >.git/info/always_exclude <<\EOF && | ||
/dir1/a | ||
EOF | ||
git status -u >standard && | ||
git config --local core.gvfs 512 && | ||
git status -u >with_hashmap && | ||
git config --local core.gvfs 0 && | ||
test_cmp standard with_hashmap | ||
' | ||
|
||
test_expect_success 'status with non-matching exact match' ' | ||
cat >.git/info/always_exclude <<\EOF && | ||
/dir1/dir | ||
EOF | ||
git status -u >standard && | ||
git config --local core.gvfs 512 && | ||
git status -u >with_hashmap && | ||
git config --local core.gvfs 0 && | ||
test_cmp standard with_hashmap | ||
' | ||
|
||
test_expect_success 'status with matching wildcard match' ' | ||
cat >.git/info/always_exclude <<\EOF && | ||
/dir1/* | ||
EOF | ||
git status -u >standard && | ||
git config --local core.gvfs 512 && | ||
git status -u >with_hashmap && | ||
git config --local core.gvfs 0 && | ||
test_cmp standard with_hashmap | ||
' | ||
|
||
test_expect_success 'status with non-matching wildcard match' ' | ||
cat >.git/info/always_exclude <<\EOF && | ||
/dir1/dir3/* | ||
EOF | ||
git status -u >standard && | ||
git config --local core.gvfs 512 && | ||
git status -u >with_hashmap && | ||
git config --local core.gvfs 0 && | ||
test_cmp standard with_hashmap | ||
' | ||
|
||
test_expect_success 'status with everything excluded' ' | ||
cat >.git/info/always_exclude <<\EOF && | ||
* | ||
EOF | ||
git status -u >standard && | ||
git config --local core.gvfs 512 && | ||
git status -u >with_hashmap && | ||
git config --local core.gvfs 0 && | ||
test_cmp standard with_hashmap | ||
' | ||
|
||
test_expect_success 'status with some excluded' ' | ||
cat >.git/info/always_exclude <<\EOF && | ||
* | ||
!/* | ||
EOF | ||
git status -u >standard && | ||
git config --local core.gvfs 512 && | ||
git status -u >with_hashmap && | ||
git config --local core.gvfs 0 && | ||
test_cmp standard with_hashmap | ||
' | ||
|
||
test_expect_success 'status with less excluded' ' | ||
cat >.git/info/always_exclude <<\EOF && | ||
* | ||
!/* | ||
!/dir1 | ||
!/dir1/* | ||
EOF | ||
git status -u >standard && | ||
git config --local core.gvfs 512 && | ||
git status -u >with_hashmap && | ||
git config --local core.gvfs 0 && | ||
test_cmp standard with_hashmap | ||
' | ||
|
||
test_expect_success 'status with nothing excluded' ' | ||
cat >.git/info/always_exclude <<\EOF && | ||
* | ||
!/* | ||
!/dir1 | ||
!/dir1/* | ||
!/dir1/dir2 | ||
!/dir1/dir2/* | ||
EOF | ||
git status -u >standard && | ||
git config --local core.gvfs 512 && | ||
git status -u >with_hashmap && | ||
git config --local core.gvfs 0 && | ||
test_cmp standard with_hashmap | ||
' | ||
|
||
test_done |