summaryrefslogtreecommitdiff
path: root/01_Internal.zsh
diff options
context:
space:
mode:
Diffstat (limited to '01_Internal.zsh')
-rw-r--r--01_Internal.zsh89
1 files changed, 62 insertions, 27 deletions
diff --git a/01_Internal.zsh b/01_Internal.zsh
index 42d4af4..18d979f 100644
--- a/01_Internal.zsh
+++ b/01_Internal.zsh
@@ -172,6 +172,55 @@ __get_git_fullstatus ()
}
+git_rebase_steps() {
+ GIT_DIR=$(git rev-parse --git-dir 2>&-)
+ if [ -d $GIT_DIR/rebase-merge ]
+ then
+ REBASE_DIR=$GIT_DIR/rebase-merge
+ else
+ REBASE_DIR=$GIT_DIR/rebase-apply
+ fi
+
+ if [ "$REBASE_DIR" = "$GIT_DIR/rebase-merge" ]
+ then
+ if [ -e ${REBASE_DIR}/done ]
+ then
+ current=$(< $REBASE_DIR/done wc -l)
+ else
+ current=0
+ fi
+ last=$(( $current + $(< $REBASE_DIR/git-rebase-todo grep -v "^#\|^[[:blank:]]*$" | wc -l) ))
+ else
+ current=$(cat $REBASE_DIR/next)
+ last=$(cat $REBASE_DIR/last)
+ fi
+
+ echo $current $last
+}
+
+git_rebase_amend() {
+ GIT_DIR=$(git rev-parse --git-dir 2>&-)
+ if [ -d $GIT_DIR/rebase-merge ]
+ then
+ REBASE_DIR=$GIT_DIR/rebase-merge
+ else
+ REBASE_DIR=$GIT_DIR/rebase-apply
+ fi
+ # amended commit
+ if [ -e $REBASE_DIR/stopped-sha ]
+ then
+ amend=$(cat $REBASE_DIR/stopped-sha)
+ elif [ -e $REBASE_DIR/amend ]
+ then
+ amend=$(cat $REBASE_DIR/amend)
+ elif [ -e $REBASE_DIR/original-commit ]
+ then
+ amend=$(cat $REBASE_DIR/original-commit)
+ fi
+
+ echo $amend
+}
+
__get_git_branch ()
{
local my_git_branch checkouted_branch commit_ish
@@ -200,7 +249,7 @@ __get_git_branch ()
commit_ish=$(git rev-parse --verify HEAD 2>/dev/null)
# Get current working GIT branch
- my_git_branch="$(git symbolic-ref --short -q HEAD)"
+ my_git_branch="$(git symbolic-ref --short -q HEAD | sed 's/^refs\///;s/^heads\///')"
#my_git_branch="$(git name-rev --name-only HEAD)"
# for future use
checkouted_branch=$my_git_branch
@@ -281,21 +330,18 @@ __get_git_branch ()
local rebase onto amend current last
local REBASE_DIR
- if [ -d $GIT_DIR/rebase-merge ]
- then
- REBASE_DIR=$GIT_DIR/rebase-merge
- else
- REBASE_DIR=$GIT_DIR/rebase-apply
- fi
+ if [ -d $GIT_DIR/rebase-merge ]
+ then
+ REBASE_DIR=$GIT_DIR/rebase-merge
+ else
+ REBASE_DIR=$GIT_DIR/rebase-apply
+ fi
- if [ "$REBASE_DIR" = "$GIT_DIR/rebase-merge" ]
- then
- current=$(< $REBASE_DIR/done wc -l)
- last=$(( $current + $(< $REBASE_DIR/git-rebase-todo grep -v "^#\|^[[:blank:]]*$" | wc -l) ))
- else
- current=$(cat $REBASE_DIR/next)
- last=$(cat $REBASE_DIR/last)
- fi
+ steps=$(git_rebase_steps)
+ current=${steps%% *}
+ last=${steps##* }
+
+ amend=$(git_rebase_amend)
rebase="["$C_$_prompt_colors[bold_generic]$_C
#while [ $current -gt 0 ] ; do rebase+=$T_"a"$_T ; current=$(( $current - 1 )) ; done
@@ -307,18 +353,6 @@ __get_git_branch ()
# base
onto=$(git name-rev --name-only --always --no-undefined $(cat $REBASE_DIR/onto) 2>&- | __cleanup_git_branch_name)
- # amended commit
- if [ -e $REBASE_DIR/stopped-sha ]
- then
- amend=$(cat $REBASE_DIR/stopped-sha)
- elif [ -e $REBASE_DIR/amend ]
- then
- amend=$(cat $REBASE_DIR/amend)
- elif [ -e $REBASE_DIR/original-commit ]
- then
- amend=$(cat $REBASE_DIR/original-commit)
- fi
- #
if [ "$amend" != "$commit_ish" ]
then
#amend=$(git name-rev --name-only --always --no-undefined "$amend" 2>/dev/null | __cleanup_git_branch_name)
@@ -361,6 +395,7 @@ __get_git_tracking_status() {
local git_tracking_status=""
my_git_branch="$(git symbolic-ref --short -q HEAD)"
+ #my_git_branch="$(git name-rev --name-only HEAD)"
if [ "$my_git_branch" ]
then