#!/bin/sh # # git-backdate-tag: Change the date of an existing tag, replacing the # tag reference with the newly-generated tag object. # # Usage: git-backdate-tag TAG DATE usage () { echo "Usage: git-backdate-tag TAG DATE" } if [ -n "$3" ]; then usage exit 1 elif [ -z "$2" ]; then usage exit 1 fi # Set parameters tag="$1" date=$(date --date="$2" +%s) if [ $? -ne 0 ]; then echo Could not parse date exit 1 fi # Replace old date with new date newtagobj=$(git cat-file tag "$tag" | \ sed -r -e "s/^(tagger .+) ([^ \\n]+) ([^ \\n]+)\$/\1 $date \3/1" | \ git mktag) if [ $? -ne 0 ]; then echo Could not create replacement tag object exit 1 fi # Set tag to new tag object git update-ref refs/tags/"$tag" $newtagobj