summaryrefslogtreecommitdiff
path: root/01_Functions.zsh
diff options
context:
space:
mode:
authorHugues Hiegel <hugues@hiegel.fr>2009-05-11 14:36:27 +0200
committerHugues Hiegel <hugues@hiegel.fr>2009-05-11 14:36:27 +0200
commit0796880938524720b878299ede88b6e19f9d6376 (patch)
treecddfe245399b6c684ed789061d5d3f719040a8fe /01_Functions.zsh
parentbdc123e5c3140f7719cc4949f477ee8e966ba6d4 (diff)
[Funcs] testing if we are on an not-yet-initialized-git-repos
Diffstat (limited to '01_Functions.zsh')
-rw-r--r--01_Functions.zsh21
1 files changed, 17 insertions, 4 deletions
diff --git a/01_Functions.zsh b/01_Functions.zsh
index acec467..50d9b9e 100644
--- a/01_Functions.zsh
+++ b/01_Functions.zsh
@@ -76,15 +76,19 @@ get_git_branch ()
local my_git_branch REBASE
if [ ! -z "$DO_NOT_CHECK_GIT_BRANCH" ]
- then return
+ then
+ return
fi
- [ "$( ( git-ls-tree HEAD . 2>&- ; git-ls-files . 2>&- ) | head -n 1)" == "" ] && return
+ [ "$( git-ls-files . 2>&- | head -n1)" == "" -a ! -d .git -a "$(git-rev-parse --is-inside-git-dir 2>&-)" != "true" ] && return
+
+ GIT_DIR=$(git-rev-parse --git-dir)
# Rebase in progress ?
REBASE="";
- [ -e $(git-rev-parse --git-dir)/../.dotest/rebasing ] && REBASE="rebase:"
- [ -d $(git-rev-parse --git-dir)/rebase-merge ] && REBASE="rebase:"
+ [ -e $GIT_DIR/../.dotest/rebasing \
+ -o -d $GIT_DIR/rebase-merge ] && \
+ REBASE="rebase:"
# Get current working GIT branch
my_git_branch="$REBASE$(git-branch 2>&- | grep -E '^\* ' | cut -c3-)"
@@ -100,6 +104,10 @@ get_git_branch ()
then
my_git_branch="($REBASE$(git-rev-parse HEAD 2>&-))"
fi
+ elif [ -f $GIT_DIR/HEAD ]
+ then
+ # On an initial commit !
+ my_git_branch="<$(basename $GIT_DIR/$(cat $GIT_DIR/HEAD | cut -d' ' -f2))>"
fi
echo $my_git_branch
@@ -128,12 +136,16 @@ get_git_status ()
not_up_to_date="yes"
fi
+ GIT_DIR=$(git-rev-parse --git-dir 2>/dev/null)
+
if [ "$cached" != "" -a "$not_up_to_date" != "" ] ; then
my_git_status="$git_colors[cached_and_not_up_to_date]"
elif [ "$cached" != "" ] ; then
my_git_status="$git_colors[cached]"
elif [ "$not_up_to_date" != "" ] ; then
my_git_status="$git_colors[not_up_to_date]"
+ elif [ ! -s $GIT_DIR/$(cat $GIT_DIR/HEAD | cut -d' ' -f2) ] ; then
+ my_git_status="$git_colors[init_in_progress]"
else
my_git_status="$git_colors[up_to_date]"
fi
@@ -212,6 +224,7 @@ set_prompt_colors ()
git_colors[cached]="$prompt_colors[to_be_commited]" # git changes in cache
git_colors[cached_and_not_up_to_date]="$prompt_colors[not_up_to_date];$color[bold]"
git_colors[not_up_to_date]="$prompt_colors[not_up_to_date];$color[normal]" # git changes in working tree
+ git_colors[init_in_progress]="$color[black];$color[bold]" # initialization
git_colors[up_to_date]="$prompt_colors[up_to_date]" # git up-to-date
}