Skip to content

Commit 14d7649

Browse files
committed
bash prompt: avoid command substitution when checking for untracked files
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 <[email protected]>
1 parent dd0b72c commit 14d7649

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

contrib/completion/git-prompt.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ __git_ps1 ()
442442

443443
if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] &&
444444
[ "$(git config --bool bash.showUntrackedFiles)" != "false" ] &&
445-
[ -n "$(git ls-files --others --exclude-standard)" ]
445+
git ls-files --others --exclude-standard --error-unmatch -- '*' >/dev/null 2>/dev/null
446446
then
447447
u="%${ZSH_VERSION+%}"
448448
fi

0 commit comments

Comments
 (0)