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 <martinerikwerner@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Martin Erik Werner committed
Feb 18, 2013 at 23:59 UTC
31e6a4e6131ae2b7afd6bd0ba7919bf246e6c474
1 file changed
+13
-14
contrib/completion/git-prompt.sh
+13
-14
@@ -320,26 +320,25 @@ __git_ps1 ()
320
b="GIT_DIR!"
321
fi
322
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="#"
331
fi
332
fi
333
if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
334
git rev-parse --verify refs/stash >/dev/null 2>&1 && s="$"
335
fi
336
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="%"
342
fi
343
344
if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then