Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 31e6a4e

Browse files
ienorandgitster
authored andcommitted
shell-prompt: clean up nested if-then
Minor clean up of if-then nesting in checks for environment variables and config options. No functional changes. Signed-off-by: Martin Erik Werner <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4cb8a83 commit 31e6a4e

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

contrib/completion/git-prompt.sh

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -320,26 +320,25 @@ __git_ps1 ()
320320
b="GIT_DIR!"
321321
fi
322322
elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
323-
if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
324-
if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
325-
git diff --no-ext-diff --quiet --exit-code || w="*"
326-
if git rev-parse --quiet --verify HEAD >/dev/null; then
327-
git diff-index --cached --quiet HEAD -- || i="+"
328-
else
329-
i="#"
330-
fi
323+
if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ] &&
324+
[ "$(git config --bool bash.showDirtyState)" != "false" ]
325+
then
326+
git diff --no-ext-diff --quiet --exit-code || w="*"
327+
if git rev-parse --quiet --verify HEAD >/dev/null; then
328+
git diff-index --cached --quiet HEAD -- || i="+"
329+
else
330+
i="#"
331331
fi
332332
fi
333333
if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
334334
git rev-parse --verify refs/stash >/dev/null 2>&1 && s="$"
335335
fi
336336

337-
if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then
338-
if [ "$(git config --bool bash.showUntrackedFiles)" != "false" ]; then
339-
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
340-
u="%"
341-
fi
342-
fi
337+
if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] &&
338+
[ "$(git config --bool bash.showUntrackedFiles)" != "false" ] &&
339+
[ -n "$(git ls-files --others --exclude-standard)" ]
340+
then
341+
u="%"
343342
fi
344343

345344
if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then

0 commit comments

Comments
 (0)