From 6046fecd2148d7ab42e9c68bcc8ce04d74fe10cd Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Wed, 7 May 2014 09:07:56 +0200 Subject: [PATCH] vcsh: Make status show commits ahead/behind remote This is work in progress: * It does not deal with repos without a remote tracking branch * It does not share any info if run on a single repo * I should probably factor this out in a new function github: in response to richih/vcsh#123 --- vcsh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vcsh b/vcsh index 18cd9e5..0ec2bba 100755 --- a/vcsh +++ b/vcsh @@ -314,6 +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" git status --short --untracked-files='no' VCSH_COMMAND_RETURN_CODE=$? echo -- 2.39.2