#!/bin/sh
#
# man_from_git - generate man page outputs from git repositories

for p in /home/src/src/*; do
  test -d "${p}" || continue

  GIT_DIR="${p}" git ls-tree --name-only master | while read -r f; do
    # shellcheck disable=SC2249
    case "${f}" in
      *.[0-9])
        GIT_DIR="${p}" git show "master:${f}" | mandoc -T utf8 | col -bx >"${f}.txt"
        GIT_DIR="${p}" git show "master:${f}" | mandoc -T html >"${f}.html"
        ;;
    esac
  done
done
