diff --git a/mgitstatus b/mgitstatus index 9330e36..6c7f621 100755 --- a/mgitstatus +++ b/mgitstatus @@ -30,6 +30,7 @@ You can limit output with the following options: --no-uncommitted --no-untracked --no-stashes + --no-branch EOF } @@ -45,6 +46,7 @@ NO_UPSTREAM=0 NO_UNCOMMITTED=0 NO_UNTRACKED=0 NO_STASHES=0 +NO_BRANCH=0 DEPTH=2 while [ -n "$1" ]; do @@ -89,6 +91,9 @@ while [ -n "$1" ]; do if [ "$1" = "--no-stashes" ]; then NO_STASHES=1 fi + if [ "$1" = "--no-branch" ]; then + NO_BRANCH=1 + fi if [ "$1" = "-d" ] || [ "$1" = "--depth" ]; then DEPTH="$2" echo "$DEPTH" | grep -E "^[0-9]+$" > /dev/null 2>&1 @@ -242,6 +247,7 @@ for DIR in "${@:-"."}"; do # Build up the status string IS_OK=0 # 0 = Repo needs something, 1 = Repo needs nothing ('ok') STATUS_NEEDS="" + BRANCH="" if [ -n "$NEEDS_PUSH_BRANCHES" ] && [ "$NO_PUSH" -eq 0 ]; then STATUS_NEEDS="${STATUS_NEEDS}${C_NEEDS_PUSH}Needs push ($NEEDS_PUSH_BRANCHES)${C_RESET} " fi @@ -264,10 +270,13 @@ for DIR in "${@:-"."}"; do IS_OK=1 STATUS_NEEDS="${STATUS_NEEDS}${C_OK}ok${C_RESET} " fi + if [ "$NO_BRANCH" -eq 0 ]; then + BRANCH=" ($(git --git-dir "$GIT_DIR" rev-parse --abbrev-ref HEAD))" + fi # Print the output, unless repo is 'ok' and -e was specified if [ "$IS_OK" -ne 1 ] || [ "$EXCLUDE_OK" -ne 1 ]; then - printf "${PROJ_DIR}: $STATUS_NEEDS\n" + printf "${PROJ_DIR}${BRANCH}: $STATUS_NEEDS\n" fi done done diff --git a/mgitstatus.1 b/mgitstatus.1 index a4cfec2..a1f5c06 100644 --- a/mgitstatus.1 +++ b/mgitstatus.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pandoc 1.19.2.4 +.\" Automatically generated by Pandoc 2.9.2 .\" .TH "MGITSTATUS" "1" "Jul 2019" "" "" .hy @@ -8,108 +8,87 @@ mgitstatus \[en] Show uncommitted, untracked and unpushed changes for multiple Git repos. .SH SYNOPSIS .PP -\f[B]mgitstatus\f[] [\f[B]\-\-version\f[]] [\f[B]\-w\f[]] [\f[B]\-e\f[]] -[\f[B]\-f\f[]] [\f[B]\-\-no\-X\f[]] [\f[B]\-d/\-\-depth\f[]=2] -[\f[B]DIR\f[] [\f[B]DIR\f[]]...] +\f[B]mgitstatus\f[R] [\f[B]\[en]version\f[R]] [\f[B]-w\f[R]] +[\f[B]-e\f[R]] [\f[B]-f\f[R]] [\f[B]\[en]no-X\f[R]] +[\f[B]-d/\[en]depth\f[R]=2] [\f[B]DIR\f[R] [\f[B]DIR\f[R]]\&...] .SH DESCRIPTION .PP -\f[B]mgitstatus\f[] shows uncommited, untracked and unpushed changes in +\f[B]mgitstatus\f[R] shows uncommited, untracked and unpushed changes in multiple Git repositories. -By default, \f[B]mgitstatus\f[] scans two directories deep. -This can be changed with the \f[C]\-d\f[] (\f[C]\-\-depth\f[]) option. -If \f[B]DEPTH\f[] is 0, the scan is infinitely deep. +By default, \f[B]mgitstatus\f[R] scans two directories deep. +This can be changed with the \f[C]-d\f[R] (\f[C]--depth\f[R]) option. +If \f[B]DEPTH\f[R] is 0, the scan is infinitely deep. .PP mgitstatus shows: .IP \[bu] 2 -\f[B]Uncommitted changes\f[] if there are unstaged or uncommitted +\f[B]Uncommitted changes\f[R] if there are unstaged or uncommitted changes on the checked out branch. .IP \[bu] 2 -\f[B]Untracked files\f[] if there are untracked files which are not +\f[B]Untracked files\f[R] if there are untracked files which are not ignored. .IP \[bu] 2 -\f[B]Needs push (BRANCH)\f[] if the branch is tracking a (remote) branch -which is behind. +\f[B]Needs push (BRANCH)\f[R] if the branch is tracking a (remote) +branch which is behind. .IP \[bu] 2 -\f[B]Needs upstream (BRANCH)\f[] if a branch does not have a local or +\f[B]Needs upstream (BRANCH)\f[R] if a branch does not have a local or remote upstream branch configured. Changes in the branch may otherwise never be pushed or merged. .IP \[bu] 2 -\f[B]Needs pull (BRANCH)\f[] if the branch is tracking a (remote) branch -which is ahead. +\f[B]Needs pull (BRANCH)\f[R] if the branch is tracking a (remote) +branch which is ahead. This requires that the local git repo already knows about the remote -changes (i.e. -you\[aq]ve done a fetch), or that you specify the \-f option. +changes (i.e.\ you\[cq]ve done a fetch), or that you specify the -f +option. mgitstatus does NOT contact the remote by default. .IP \[bu] 2 -\f[B]X stashes\f[] if there are stashes. +\f[B]X stashes\f[R] if there are stashes. .PP Since there are a lot of different states a git repository can be in, mgitstatus makes no guarantees that all states are taken into account. .SH OPTIONS .TP -.B \f[B]\-\-version\f[] +\f[B]\[en]version\f[R] Show version -.RS -.RE .TP -.B \f[B]\-w\f[] +\f[B]-w\f[R] Warn about dirs that are not Git repositories -.RS -.RE .TP -.B \f[B]\-e\f[] -Exclude repos that are \[aq]ok\[aq] -.RS -.RE +\f[B]-e\f[R] +Exclude repos that are `ok' .TP -.B \f[B]\-f\f[] -Do a \[aq]git fetch\[aq] on each repo (slow for many repos) -.RS -.RE +\f[B]-f\f[R] +Do a `git fetch' on each repo (slow for many repos) .TP -.B \f[B]\-c\f[] +\f[B]-c\f[R] Force color output (preserve colors when using pipes) -.RS -.RE .TP -.B \f[B]\-d, \-\-depth=2\f[] +\f[B]-d, \[en]depth=2\f[R] Scan this many directories deep. Default is 2. -If \f[B]0\f[], the scan is infinitely deep -.RS -.RE +If \f[B]0\f[R], the scan is infinitely deep .PP You can limit output with the following options: .TP -.B \f[B]\-\-no\-push\f[] +\f[B]\[en]no-push\f[R] Do not show branches that need a push. -.RS -.RE .TP -.B \f[B]\-\-no\-pull\f[] +\f[B]\[en]no-pull\f[R] Do not show branches that need a pull. -.RS -.RE .TP -.B \f[B]\-\-no\-upstream\f[] +\f[B]\[en]no-upstream\f[R] Do not show branches that need an upstream. -.RS -.RE .TP -.B \f[B]\-\-no\-uncommited\f[] +\f[B]\[en]no-uncommited\f[R] Do not show branches that have unstaged or uncommitted changes. -.RS -.RE .TP -.B \f[B]\-\-no\-untracked\f[] +\f[B]\[en]no-untracked\f[R] Do not show branches that have untracked files. -.RS -.RE .TP -.B \f[B]\-\-no\-stashes\f[] +\f[B]\[en]no-stashes\f[R] Do now show stashes -.RS -.RE +.TP +\f[B]\[en]no-branch\f[R] +Do now show current branch .SH EXAMPLES .PP The following command scans two directories deep for Git projects and @@ -117,44 +96,44 @@ shows their status: .IP .nf \f[C] -$\ mgitstatus\ -\&./fboender/sla:\ ok\ -\&./fboender/multi\-git\-status:\ Needs\ push\ (master)\ Untracked\ files -\&./other/peewee:\ ok\ -\f[] +$ mgitstatus +\&./fboender/sla: ok +\&./fboender/multi-git-status: Needs push (master) Untracked files +\&./other/peewee: ok +\f[R] .fi .PP To scan deeper (three dirs instead of two) in the current dir: .IP .nf \f[C] -$\ mgitstatus\ \-d\ 3 -\f[] +$ mgitstatus -d 3 +\f[R] .fi .PP -The following command scans three levels deep in \f[C]/opt/deploy/\f[] -and hides repos that are \[aq]ok\[aq]. +The following command scans three levels deep in \f[C]/opt/deploy/\f[R] +and hides repos that are `ok'. It does not show stashes: .IP .nf \f[C] -$\ mgitstatus\ \-e\ \-\-no\-stashes\ \-d\ 3\ /opt/deploy -\f[] +$ mgitstatus -e --no-stashes -d 3 /opt/deploy +\f[R] .fi .PP -To ignore a repo, set the \f[C]mgitstatus.ignore\f[] git configuration -option for that repo to \f[C]true\f[]. +To ignore a repo, set the \f[C]mgitstatus.ignore\f[R] git configuration +option for that repo to \f[C]true\f[R]. E.g.: .IP .nf \f[C] -$\ cd\ stupidrepo -$\ git\ config\ \-\-local\ mgitstatus.ignore\ true -\f[] +$ cd stupidrepo +$ git config --local mgitstatus.ignore true +\f[R] .fi .SH COPYRIGHT .PP -Copyright 2016\-2020, Ferry Boender. +Copyright 2016-2020, Ferry Boender. .PP Licensed under the MIT license. For more information, see the LICENSE.txt file. diff --git a/mgitstatus.1.md b/mgitstatus.1.md index d9f0f8c..1d52cd3 100644 --- a/mgitstatus.1.md +++ b/mgitstatus.1.md @@ -81,6 +81,8 @@ You can limit output with the following options: **--no-stashes** : Do now show stashes +**--no-branch** +: Do now show current branch # EXAMPLES