Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show current branch #31

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion mgitstatus
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ You can limit output with the following options:
--no-uncommitted
--no-untracked
--no-stashes
--no-branch

EOF
}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
127 changes: 53 additions & 74 deletions mgitstatus.1
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -8,153 +8,132 @@ 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
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.
Expand Down
2 changes: 2 additions & 0 deletions mgitstatus.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down