diff options
author | Rudy Rigot <rudy.rigot@gmail.com> | 2022-11-30 01:52:16 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-12-01 07:27:41 +0100 |
commit | ecbc23e4c580e9a204b7b463046f7bb3d11f8749 (patch) | |
tree | 71970616594c98d77537294fb40054765a0b68db /t/t7508-status.sh | |
parent | Git 2.39-rc0 (diff) | |
download | git-ecbc23e4c580e9a204b7b463046f7bb3d11f8749.tar.xz git-ecbc23e4c580e9a204b7b463046f7bb3d11f8749.zip |
status: modernize git-status "slow untracked files" advice
`git status` can be slow when there are a large number of
untracked files and directories since Git must search the entire
worktree to enumerate them. When it is too slow, Git prints
advice with the elapsed search time and a suggestion to disable
the search using the `-uno` option. This suggestion also carries
a warning that might scare off some users.
However, these days, `-uno` isn't the only option. Git can reduce
the time taken to enumerate untracked files by caching results from
previous `git status` invocations, when the `core.untrackedCache`
and `core.fsmonitor` features are enabled.
Update the `git status` man page to explain these configuration
options, and update the advice to provide more detail about the
current configuration and to refer to the updated documentation.
Signed-off-by: Rudy Rigot <rudy.rigot@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7508-status.sh')
-rwxr-xr-x | t/t7508-status.sh | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/t/t7508-status.sh b/t/t7508-status.sh index 2b7ef6c41a..aed07c5b62 100755 --- a/t/t7508-status.sh +++ b/t/t7508-status.sh @@ -1676,4 +1676,74 @@ test_expect_success 'racy timestamps will be fixed for dirty worktree' ' ! test_is_magic_mtime .git/index ' +test_expect_success 'setup slow status advice' ' + GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main git init slowstatus && + ( + cd slowstatus && + cat >.gitignore <<-\EOF && + /actual + /expected + /out + EOF + git add .gitignore && + git commit -m "Add .gitignore" && + git config advice.statusuoption true + ) +' + +test_expect_success 'slow status advice when core.untrackedCache and fsmonitor are unset' ' + ( + cd slowstatus && + git config core.untrackedCache false && + git config core.fsmonitor false && + GIT_TEST_UF_DELAY_WARNING=1 git status >actual && + cat >expected <<-\EOF && + On branch main + + It took 3.25 seconds to enumerate untracked files. + See '\''git help status'\'' for information on how to improve this. + + nothing to commit, working tree clean + EOF + test_cmp expected actual + ) +' + +test_expect_success 'slow status advice when core.untrackedCache true, but not fsmonitor' ' + ( + cd slowstatus && + git config core.untrackedCache true && + git config core.fsmonitor false && + GIT_TEST_UF_DELAY_WARNING=1 git status >actual && + cat >expected <<-\EOF && + On branch main + + It took 3.25 seconds to enumerate untracked files. + See '\''git help status'\'' for information on how to improve this. + + nothing to commit, working tree clean + EOF + test_cmp expected actual + ) +' + +test_expect_success 'slow status advice when core.untrackedCache true, and fsmonitor' ' + ( + cd slowstatus && + git config core.untrackedCache true && + git config core.fsmonitor true && + GIT_TEST_UF_DELAY_WARNING=1 git status >actual && + cat >expected <<-\EOF && + On branch main + + It took 3.25 seconds to enumerate untracked files, + but the results were cached, and subsequent runs may be faster. + See '\''git help status'\'' for information on how to improve this. + + nothing to commit, working tree clean + EOF + test_cmp expected actual + ) +' + test_done |