From 35d1c19fd0099ffa87098e1bf7433f83a6fc2d18 Mon Sep 17 00:00:00 2001
From: Richard Hartmann <richih@debian.org>
Date: Wed, 22 Oct 2014 23:35:35 +0200
Subject: [PATCH 1/1] vcsh: Make status() show commit offsets to remote
 tracking branch

github: Fixes richih/vcsh#123
---
 vcsh | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/vcsh b/vcsh
index 0ec2bba..9d399d4 100755
--- a/vcsh
+++ b/vcsh
@@ -314,12 +314,12 @@ status() {
 			echo "$VCSH_REPO_NAME:"
 			GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR
 			use
-			# TODO repos without remote tracking branch error out
-			remote_tracking_branch=$(git rev-parse --abbrev-ref --symbolic-full-name @{u})
-			commits_behind=$(git log ..${remote_tracking_branch} --oneline | wc -l)
-			commits_ahead=$(git log ${remote_tracking_branch}.. --oneline | wc -l)
-			[ ${commits_behind} -ne 0 ] && echo "Behind $remote_tracking_branch by $commits_behind commits"
-			[ ${commits_ahead} -ne 0 ] && echo "Ahead of $remote_tracking_branch by $commits_ahead commits"
+			remote_tracking_branch=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2> /dev/null) && {
+				commits_behind=$(git log ..${remote_tracking_branch} --oneline | wc -l)
+				commits_ahead=$(git log ${remote_tracking_branch}.. --oneline | wc -l)
+				[ ${commits_behind} -ne 0 ] && echo "Behind $remote_tracking_branch by $commits_behind commits"
+				[ ${commits_ahead} -ne 0 ] && echo "Ahead of $remote_tracking_branch by $commits_ahead commits"
+			}
 			git status --short --untracked-files='no'
 			VCSH_COMMAND_RETURN_CODE=$?
 			echo
-- 
2.39.5