#!/bin/sh
#
# grc - check whether a directory is a Git repository with uncommitted changes

# enter given directory or bail
cd -- "${1:-.}" || exit

# if not a Git repository at all, warn explicitly
if ! isgr; then
  printf >&2 'grc: Not a Git repository\n'
  exit 1
fi

# exit 0  if the first command gives any output (added files) or the second one
# exits 1 (inverted; differences in tracked files)
# shellcheck disable=SC2312
[ -n "$(git ls-files --others --exclude-standard)" ] \
  || ! git diff-index --quiet HEAD
