Simplify git empty repo check

Exclude text string check. Only log run Ok.
This commit is contained in:
Egorov N.V 2016-08-21 11:35:06 +03:00
commit 4fa4f96c66

View file

@ -37,7 +37,7 @@ ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[cyan]%}"
function git_time_since_commit() {
if git rev-parse --git-dir > /dev/null 2>&1; then
# Only proceed if there is actually a commit.
if [[ $(git log -n 1 2>&1 > /dev/null | grep -Ec "^fatal: bad default revision") == 0 ]]; then
if git log -n 1 > /dev/null 2>&1; then
# Get the last commit.
last_commit=`git log --pretty=format:'%at' -1 2> /dev/null`
now=`date +%s`