#!/bin/bash
#
# check whether current directory is inside a git repository
#

is_git_repo() {
  git rev-parse --show-toplevel > /dev/null 2>&1
  result=$?
  if test $result != 0; then
    >&2 echo 'Not a git repo!'
    exit $result
  fi
}

is_git_repo

if test "$1" = "--all"; then
  git shortlog -n -s $@ | awk '{print substr($0,index($0,$2)) " (" $1 ")"}'
  echo
fi

echo total `git rev-list --count HEAD`
