When entering a git working dir, optionally run a forked process that stat all files in the whole workdir and therefore loads stat information to RAM which will speedup things like git status and so on. The feature is optional and by default it's off. Signed-off-by: Fredrik Gustafsson <iveqy@xxxxxxxxx> --- contrib/completion/git-prompt.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh index 341422a..e67bc97 100644 --- a/contrib/completion/git-prompt.sh +++ b/contrib/completion/git-prompt.sh @@ -78,6 +78,12 @@ # If you would like a colored hint about the current dirty state, set # GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on # the colored output of "git status -sb". +# +# When enter a git work dir you can have a forked process run +# stat on all files in the top level directory for git and down. +# This will decrease later calls to git status and alike because +# stat info will already be loaded into RAM. set GIT_PRE_STAT to +# a nonempty value. # __gitdir accepts 0 or 1 arguments (i.e., location) # returns location of .git repo @@ -222,6 +228,19 @@ __git_ps1_show_upstream () } +# Forks and recursive do a stat from the toplevel git dir. +# This will load inodes into RAM for faster access when running +# A git command, like git show. +__git_recursive_stat () +{ + if test ! -e /tmp/gitbash.lock + then + touch /tmp/gitbash.lock + cd $(git rev-parse --show-toplevel) + find . | xargs stat 2&> /dev/null + rm /tmp/gitbash.lock + fi +} # __git_ps1 accepts 0 or 1 arguments (i.e., format string) # when called from PS1 using command substitution @@ -320,6 +339,10 @@ __git_ps1 () b="GIT_DIR!" fi elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then + if [ -n "${GIT_PRE_STAT-}" ]; + then + (__git_recursive_stat 2&> /dev/null &) + fi if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ] && [ "$(git config --bool bash.showDirtyState)" != "false" ] then -- 1.8.1.5 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html