#!/bin/sh
# gitdirs -- list all the subdirectories of the current directory 
#            that are GIT directories
#
# SUMMARY: If the current directory is a GIT directory,
#          then it outputs . ;
#          otherwise, it lists on stdout all the immediate subdirectories
#          of . that are GIT directories (with relative pathnames).
#
# AUTHOR:	Gary T. Leavens

[ -n "$echo" ] && set -x

USAGE='gitdirs'

# gitdirs -- Print all immediate subdirectories that are GIT directories
# This only prints relative directory names.
gitdirs()
{
# no parameters
if test $# -ne 0
then
	echo "$USAGE" >&2
	exit 2
fi

if test -d .git
then
	echo .
else
    SUBDIRS=`echo */.git`
    if test "$SUBDIRS" \!= '*/.git'
    then
	echo "$SUBDIRS" | sed -e 's@/.git@@g'
    fi
fi
}

gitdirs $*

