@@ -15,6 +15,7 @@ repositories. By default, mgitstatus scans two directories deep. This can be
1515changed with the -d (--depth) option. If DEPTH is 0, the scan is infinitely
1616deep.
1717
18+ -b Show currently checked out branch
1819 -c Force color output (preserve colors when using pipes)
1920 -d, --depth=2 Scan this many directories deep
2021 -e Exclude repos that are 'ok'
@@ -54,11 +55,15 @@ NO_STASHES=0
5455NO_DEPTH=0
5556THROTTLE=0
5657DEPTH=2
58+ SHOW_CUR_BRANCH=0
5759
5860while [ -n " $1 " ]; do
5961 # Stop reading when we've run out of options.
6062 [ " $( printf " %s" " $1 " | cut -c 1) " != " -" ] && break
6163
64+ if [ " $1 " = " -b" ]; then
65+ SHOW_CUR_BRANCH=1
66+ fi
6267 if [ " $1 " = " -c" ]; then
6368 FORCE_COLOR=1
6469 fi
@@ -221,6 +226,13 @@ for DIR in "${@:-"."}"; do
221226 # Refresh the index, or we might get wrong results.
222227 git --work-tree " $( dirname " $GIT_DIR " ) " --git-dir " $GIT_DIR " update-index -q --refresh > /dev/null 2>&1
223228
229+ # Get current branch, if "-b" is specified
230+ if [ " $SHOW_CUR_BRANCH " -eq 1 ]; then
231+ CUR_BRANCH=" ($( git --git-dir " $GIT_DIR " rev-parse --abbrev-ref HEAD) )"
232+ else
233+ CUR_BRANCH=" "
234+ fi
235+
224236 # Find all remote branches that have been checked out and figure out if
225237 # they need a push or pull. We do this with various tests and put the name
226238 # of the branches in NEEDS_XXXX, seperated by newlines. After we're done,
@@ -302,44 +314,44 @@ for DIR in "${@:-"."}"; do
302314 if [ -n " $NEEDS_PUSH_BRANCHES " ] && [ " $NO_PUSH " -eq 0 ]; then
303315 THIS_STATUS=" ${C_NEEDS_PUSH} Needs push ($NEEDS_PUSH_BRANCHES )${C_RESET} "
304316 STATUS_NEEDS=" ${STATUS_NEEDS}${THIS_STATUS} "
305- [ " $FLATTEN " -eq 1 ] && printf " ${PROJ_DIR} : $THIS_STATUS \n"
317+ [ " $FLATTEN " -eq 1 ] && printf " ${PROJ_DIR} $CUR_BRANCH : $THIS_STATUS \n"
306318 fi
307319 if [ -n " $NEEDS_PULL_BRANCHES " ] && [ " $NO_PULL " -eq 0 ]; then
308320 THIS_STATUS=" ${C_NEEDS_PULL} Needs pull ($NEEDS_PULL_BRANCHES )${C_RESET} "
309321 STATUS_NEEDS=" ${STATUS_NEEDS}${THIS_STATUS} "
310- [ " $FLATTEN " -eq 1 ] && printf " ${PROJ_DIR} : $THIS_STATUS \n"
322+ [ " $FLATTEN " -eq 1 ] && printf " ${PROJ_DIR} $CUR_BRANCH : $THIS_STATUS \n"
311323 fi
312324 if [ -n " $NEEDS_UPSTREAM_BRANCHES " ] && [ " $NO_UPSTREAM " -eq 0 ]; then
313325 THIS_STATUS=" ${C_NEEDS_UPSTREAM} Needs upstream ($NEEDS_UPSTREAM_BRANCHES )${C_RESET} "
314326 STATUS_NEEDS=" ${STATUS_NEEDS}${THIS_STATUS} "
315- [ " $FLATTEN " -eq 1 ] && printf " ${PROJ_DIR} : $THIS_STATUS \n"
327+ [ " $FLATTEN " -eq 1 ] && printf " ${PROJ_DIR} $CUR_BRANCH : $THIS_STATUS \n"
316328 fi
317329 if [ " $UNSTAGED " -ne 0 ] || [ " $UNCOMMITTED " -ne 0 ] && [ " $NO_UNCOMMITTED " -eq 0 ]; then
318330 THIS_STATUS=" ${C_NEEDS_COMMIT} Uncommitted changes${C_RESET} "
319331 STATUS_NEEDS=" ${STATUS_NEEDS}${THIS_STATUS} "
320- [ " $FLATTEN " -eq 1 ] && printf " ${PROJ_DIR} : $THIS_STATUS \n"
332+ [ " $FLATTEN " -eq 1 ] && printf " ${PROJ_DIR} $CUR_BRANCH : $THIS_STATUS \n"
321333 fi
322334 if [ " $UNTRACKED " != " " ] && [ " $NO_UNTRACKED " -eq 0 ]; then
323335 THIS_STATUS=" ${C_UNTRACKED} Untracked files${C_RESET} "
324336 STATUS_NEEDS=" ${STATUS_NEEDS}${THIS_STATUS} "
325- [ " $FLATTEN " -eq 1 ] && printf " ${PROJ_DIR} : $THIS_STATUS \n"
337+ [ " $FLATTEN " -eq 1 ] && printf " ${PROJ_DIR} $CUR_BRANCH : $THIS_STATUS \n"
326338 fi
327339 if [ " $STASHES " -ne 0 ] && [ " $NO_STASHES " -eq 0 ]; then
328340 THIS_STATUS=" ${C_STASHES} $STASHES stashes${C_RESET} "
329341 STATUS_NEEDS=" ${STATUS_NEEDS}${THIS_STATUS} "
330- [ " $FLATTEN " -eq 1 ] && printf " ${PROJ_DIR} : $THIS_STATUS \n"
342+ [ " $FLATTEN " -eq 1 ] && printf " ${PROJ_DIR} $CUR_BRANCH : $THIS_STATUS \n"
331343 fi
332344 if [ " $STATUS_NEEDS " = " " ]; then
333345 IS_OK=1
334346 THIS_STATUS=" ${C_OK} ok${C_RESET} "
335347 STATUS_NEEDS=" ${STATUS_NEEDS}${THIS_STATUS} "
336- [ " $FLATTEN " -eq 1 ] && [ " $EXCLUDE_OK " -ne 1 ] && printf " ${PROJ_DIR} : $THIS_STATUS \n"
348+ [ " $FLATTEN " -eq 1 ] && [ " $EXCLUDE_OK " -ne 1 ] && printf " ${PROJ_DIR} $CUR_BRANCH : $THIS_STATUS \n"
337349 fi
338350
339351 if [ " $FLATTEN " -ne 1 ]; then
340352 # Print the output, unless repo is 'ok' and -e was specified
341353 if [ " $IS_OK " -ne 1 ] || [ " $EXCLUDE_OK " -ne 1 ]; then
342- printf " ${PROJ_DIR} : $STATUS_NEEDS \n"
354+ printf " ${PROJ_DIR} $CUR_BRANCH : $STATUS_NEEDS \n"
343355 fi
344356 fi
345357
0 commit comments