#!/usr/bin/env sh
# SPDX-License-Identifier: MIT
# ──────────────────────────────────────────────────────────────────────────────
# $source: cappysan-dotfile-scripts$
# ──────────────────────────────────────────────────────────────────────────────
#
# NAME
#      git-cleanup - cleanup a repository
#
# SEE ALSO
#      git(1)
#
set -eu -o pipefail

# error if not in git repository
git show >/dev/null

if test ! -f ".git/config"; then
  echo "fatal: not at the root of the git repository" >&2
  exit 1
fi

rm -v .git/description $(ls .git/hooks/*.sample 2>/dev/null || true) 2>/dev/null || true
git gc
