Skip to content

Commit 39a9324

Browse files
committed
Added --no-depth option, to prevent recursing into dirs
1 parent 1fc44ae commit 39a9324

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ for that repo to `true`. (See "usage" below for an example).
3333

3434
# Usage
3535

36-
Usage: mgitstatus [--version] [-w] [-e] [-f] [--throttle SEC] [-c] [-d/--depth=2] [--flatten] [--no-X] [DIR [DIR]...]
36+
Usage: mgitstatus [--version] [-w] [-e] [-f] [--throttle SEC] [-c] [-d/--depth=2] [--no-depth] [--flatten] [--no-X] [DIR [DIR]...]
3737

3838
mgitstatus shows uncommitted, untracked and unpushed changes in multiple Git
3939
repositories. By default, mgitstatus scans two directories deep. This can be
@@ -47,6 +47,7 @@ for that repo to `true`. (See "usage" below for an example).
4747
--throttle SEC Wait SEC seconds between each 'git fetch' (-f option)
4848
-c Force color output (preserve colors when using pipes)
4949
-d, --depth=2 Scan this many directories deep
50+
--no-depth Do not recurse into directories (incompatible with -d)
5051
--flatten Show only one status per line
5152

5253
You can limit output with the following options:

mgitstatus

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ deep.
2222
--throttle SEC Wait SEC seconds between each 'git fetch' (-f option)
2323
-c Force color output (preserve colors when using pipes)
2424
-d, --depth=2 Scan this many directories deep
25+
--no-depth Do not recurse into directories (incompatible with -d)
2526
--flatten Show only one status per line
2627
2728
You can limit output with the following options:
@@ -49,6 +50,7 @@ NO_UPSTREAM=0
4950
NO_UNCOMMITTED=0
5051
NO_UNTRACKED=0
5152
NO_STASHES=0
53+
NO_DEPTH=0
5254
THROTTLE=0
5355
DEPTH=2
5456

@@ -101,6 +103,10 @@ while [ -n "$1" ]; do
101103
# Same as -e, but -e violates the principle of least astonishment.
102104
EXCLUDE_OK=1
103105
fi
106+
if [ "$1" = "--no-depth" ]; then
107+
# Same as -e, but -e violates the principle of least astonishment.
108+
NO_DEPTH=1
109+
fi
104110
if [ "$1" = "--throttle" ]; then
105111
THROTTLE="$2"
106112
echo "$THROTTLE" | grep -E "^[0-9]+$" > /dev/null 2>&1
@@ -158,6 +164,13 @@ FIND_OPTS=""
158164
if [ "$DEPTH" -ne 0 ]; then
159165
FIND_OPTS="$FIND_OPTS -maxdepth $DEPTH"
160166
fi
167+
if [ "$NO_DEPTH" -eq 1 ]; then
168+
# Do not recurse at all. Really, this should have been the '-d 0' option,
169+
# but that's already used for infinite recursion, and we don't want to
170+
# break backwards compatibility.
171+
FIND_OPTS="$FIND_OPTS -maxdepth 0"
172+
fi
173+
161174

162175
# Go through positional arguments (DIRs) or '.' if no argumnets are given
163176
for DIR in "${@:-"."}"; do

mgitstatus.1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ Scan this many directories deep.
7171
Default is 2.
7272
If \f[B]0\f[R], the scan is infinitely deep
7373
.TP
74+
.B \f[B]\-\-no\-depth\f[R]
75+
Do not recurse into directories (incompatible with \-d)
76+
.TP
7477
.B \f[B]\-\-flatten\f[R]
7578
Flatten output by only showing one status per line.
7679
If a repo has multiple statuses, multiple lines are shown for that repo.

mgitstatus.1.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ mgitstatus makes no guarantees that all states are taken into account.
6464
**-d, \--depth=2**
6565
: Scan this many directories deep. Default is 2. If **0**, the scan is infinitely deep
6666

67+
**\--no-depth**
68+
: Do not recurse into directories (incompatible with -d)
69+
6770
**\--flatten**
6871
: Flatten output by only showing one status per line. If a repo has multiple statuses, multiple lines are shown for that repo. This aids in grepability.
6972

0 commit comments

Comments
 (0)