From 877d1c2e813fd92f265b938089a564484ecb653f Mon Sep 17 00:00:00 2001 From: Matias Fernandez Date: Wed, 16 Jul 2014 19:01:18 -0300 Subject: [PATCH] Modify gitstatus.sh to detect local branch without tracking remote --- gitstatus.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gitstatus.sh b/gitstatus.sh index e64df13..ba210b5 100755 --- a/gitstatus.sh +++ b/gitstatus.sh @@ -111,6 +111,15 @@ else remote_ref="refs/remotes/$remote_name/${merge_name##refs/heads/}" fi + # detect if the local branch have a remote tracking branch + cmd_output=$(git rev-parse --abbrev-ref ${branch}@{upstream} 2>&1 >/dev/null) + + if [ `count_lines "$cmd_output" "fatal: No upstream"` == 1 ] ; then + has_remote_tracking=0 + else + has_remote_tracking=1 + fi + # get the revision list, and count the leading "<" and ">" revgit=`git rev-list --left-right ${remote_ref}...HEAD` num_revs=`all_lines "$revgit"` @@ -123,10 +132,15 @@ else remote="${remote}${symbols_ahead}${num_ahead}" fi fi + if [[ -z "$remote" ]] ; then remote='.' fi +if [[ "$has_remote_tracking" == "0" ]] ; then + remote='L' +fi + for w in "$branch" "$remote" $num_staged $num_conflicts $num_changed $num_untracked $num_stashed $clean ; do echo "$w" done