#!/bin/sh

main() {
   local cmd="$1"
   [ "$cmd" != "rebase" ] && return 0

   while read pre post rest ; do
      {
         git tag --points-at "$pre" 2>/dev/null || printf \\n
      } | grep '^[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}$' \
        | while read tag ; do
            git tag -f "$tag" "$post" >/dev/null 2>&1
            printf ' %s' "$tag"
      done
   done
   printf \\n
}

main "$@"
