Skip to content

Commit

Permalink
bash prompt: avoid command substitution when checking for untracked f…
Browse files Browse the repository at this point in the history
…iles

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>
  • Loading branch information
SZEDER Gábor committed Jun 24, 2013
1 parent dd0b72c commit 14d7649
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion contrib/completion/git-prompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 14d7649

Please sign in to comment.