Skip to content
Snippets Groups Projects
Commit 6046fecd authored by Richard Hartmann's avatar Richard Hartmann
Browse files

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
parent 6bc1d178
Branches
Tags
No related merge requests found
...@@ -314,6 +314,12 @@ status() { ...@@ -314,6 +314,12 @@ status() {
echo "$VCSH_REPO_NAME:" echo "$VCSH_REPO_NAME:"
GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR
use 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' git status --short --untracked-files='no'
VCSH_COMMAND_RETURN_CODE=$? VCSH_COMMAND_RETURN_CODE=$?
echo echo
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment