Skip to content
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
17 changes: 15 additions & 2 deletions mgitstatus
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ DEBUG=0
usage () {
cat << EOF >&2

Usage: $0 [--version] [-w] [-e] [-f] [--no-X] [-d/--depth=2] [DIR [DIR]...]
Usage: $0 [--version] [-b] [-w] [-e] [-f] [--no-X] [-d/--depth=2] [DIR [DIR]...]

mgitstatus shows uncommited, untracked and unpushed changes in multiple Git
repositories. By default, mgitstatus scans two directories deep. This can be
Expand All @@ -20,6 +20,7 @@ deep.
-e Exclude repos that are 'ok'
-f Do a 'git fetch' on each repo (slow for many repos)
-c Force color output (preserve colors when using pipes)
-b Show current branch
-d, --depth=2 Scan this many directories deep

You can limit output with the following options:
Expand All @@ -45,6 +46,7 @@ NO_UPSTREAM=0
NO_UNCOMMITTED=0
NO_UNTRACKED=0
NO_STASHES=0
DO_STATUS=0
DEPTH=2

while [ -n "$1" ]; do
Expand All @@ -71,6 +73,9 @@ while [ -n "$1" ]; do
if [ "$1" = "-c" ]; then
FORCE_COLOR=1
fi
if [ "$1" = "-b" ]; then
DO_STATUS=1
fi
if [ "$1" = "--no-push" ]; then
NO_PUSH=1
fi
Expand Down Expand Up @@ -239,9 +244,15 @@ for DIR in "${@:-"."}"; do
STASHES=$(git stash list | wc -l)
cd "$OLDPWD" || exit

CURRENT_BRANCH=$(git --work-tree "$(dirname "$GIT_DIR")" --git-dir "$GIT_DIR" branch --show-current)

# Build up the status string
IS_OK=0 # 0 = Repo needs something, 1 = Repo needs nothing ('ok')
STATUS_NEEDS=""
BRANCH_PRINT=""
if [ -n "$CURRENT_BRANCH" ] && [ "$CURRENT_BRANCH" != "master" ] && [ "$DO_STATUS" -eq 1 ]; then
BRANCH_PRINT="[${C_OK}${CURRENT_BRANCH}${C_RESET}] "
fi
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 @@ -262,7 +273,9 @@ for DIR in "${@:-"."}"; do
fi
if [ "$STATUS_NEEDS" = "" ]; then
IS_OK=1
STATUS_NEEDS="${STATUS_NEEDS}${C_OK}ok${C_RESET} "
STATUS_NEEDS="${BRANCH_PRINT}${STATUS_NEEDS}${C_OK}ok${C_RESET} "
else
STATUS_NEEDS="${BRANCH_PRINT}${STATUS_NEEDS}"
fi

# Print the output, unless repo is 'ok' and -e was specified
Expand Down
9 changes: 8 additions & 1 deletion mgitstatus.1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ 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]mgitstatus\f[] [\f[B]\-\-version\f[]] [\f[B]\-b\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[]]...]
.SH DESCRIPTION
Expand All @@ -21,6 +21,8 @@ If \f[B]DEPTH\f[] is 0, the scan is infinitely deep.
.PP
mgitstatus shows:
.IP \[bu] 2
\f[B]Current branch\f[] if the option -b is given.
.IP \[bu] 2
\f[B]Uncommitted changes\f[] if there are unstaged or uncommitted
changes on the checked out branch.
.IP \[bu] 2
Expand Down Expand Up @@ -52,6 +54,11 @@ Show version
.RS
.RE
.TP
.B \f[B]\-b\f[]
Print current branch (master is skipped)
.RS
.RE
.TP
.B \f[B]\-w\f[]
Warn about dirs that are not Git repositories
.RS
Expand Down
5 changes: 5 additions & 0 deletions mgitstatus.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ is infinitely deep.

mgitstatus shows:

- **Current branch** if the -b option is given. Skips 'master' branch.

- **Uncommitted changes** if there are unstaged or uncommitted changes on the
checked out branch.

Expand Down Expand Up @@ -46,6 +48,9 @@ mgitstatus makes no guarantees that all states are taken into account.
**--version**
: Show version

**-b**
: Print current branch

**-w**
: Warn about dirs that are not Git repositories

Expand Down