]> git.ipfire.org Git - thirdparty/git.git/commitdiff
bash prompt: avoid command substitution when checking for untracked files
authorSZEDER Gábor <szeder@ira.uka.de>
Fri, 12 Aug 2011 12:17:12 +0000 (14:17 +0200)
committerSZEDER Gábor <szeder@ira.uka.de>
Mon, 24 Jun 2013 16:03:37 +0000 (18:03 +0200)
When enabled, the bash prompt can indicate the presence of untracked
files with a '%' sign.  __git_ps1() checks for untracked files by running the
'$(git ls-files --others --exclude-standard)' command substitution,
and displays the indicator when there is no output.

Avoid this command substitution by additionally passing
'--error-unmatch *', and checking the command's return value.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
contrib/completion/git-prompt.sh

index afa867030de12916358d24e63c4335b4f43c8a91..5ea6a68bc0f6bc707669840f68fee680544f7c2a 100644 (file)
@@ -442,7 +442,7 @@ __git_ps1 ()
 
                if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] &&
                   [ "$(git config --bool bash.showUntrackedFiles)" != "false" ] &&
-                  [ -n "$(git ls-files --others --exclude-standard)" ]
+                  git ls-files --others --exclude-standard --error-unmatch -- '*' >/dev/null 2>/dev/null
                then
                        u="%${ZSH_VERSION+%}"
                fi