From bd6122e17804cf0537f999b3ffdec70324af3daa Mon Sep 17 00:00:00 2001 From: Aaron Jensen Date: Tue, 21 Apr 2015 22:42:12 -0700 Subject: [PATCH] Specify log format for git checks Some git configs override the default log format so `git log` alone behaves differently on different machines. This should normalize it and it simplifies the conditionals. --- lib/git.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/git.zsh b/lib/git.zsh index 118841f06..41db581f9 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -51,15 +51,15 @@ git_remote_status() { # Checks if there are commits ahead from remote function git_prompt_ahead() { - if $(echo "$(command git log @{upstream}..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then + if [ -n "$(command git log --pretty=oneline @{upstream}..HEAD 2> /dev/null)" ]; then echo "$ZSH_THEME_GIT_PROMPT_AHEAD" fi } # Gets the number of commits ahead from remote function git_commits_ahead() { - if $(echo "$(command git log @{upstream}..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then - COMMITS=$(command git log @{upstream}..HEAD | grep '^commit' | wc -l | tr -d ' ') + if [ -n "$(command git log --pretty=oneline @{upstream}..HEAD 2> /dev/null)" ]; then + COMMITS=$(command git log --pretty=oneline @{upstream}..HEAD | wc -l | tr -d ' ') echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$COMMITS$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX" fi }