git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Script to backdate tags

From
Michael Olson <mwolson@gnu.org>
Date
Sep 30, 2007, 03:16 UTC
Message-ID
<87bqbklu5r.fsf@hariken.mwolson.org>

After importing one of my projects from Arch, I wanted to add tags that indicated its major releases. Unfortunately, these tags for older releases would show up before the more recent releases in the gitweb output. I searched in vain for a way of backdating tags, and finally decided to make a script to do this for me. Here it is.

This may run into issues if someone uses the "\" character in their tag names, but I didn't want to bother fixing this until it was affirmed that this script would be considered generally useful.

#!/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

-- 
       Michael Olson -- FSF Associate Member #652     |
 http://mwolson.org/ -- Jabber: mwolson_at_hcoop.net  |  /` |\ | | |
            Sysadmin -- Hobbies: Lisp, GP2X, HCoop    | |_] | \| |_|
Projects: Emacs, Muse, ERC, EMMS, ErBot, DVC, Planner |
Next: Michael Olson
Message 1 of 7 in “Script to backdate tags”
  1. Michael OlsonSep 30, 2007
  2. Michael OlsonSep 30, 2007
  3. Junio C HamanoSep 30, 2007
  4. Michael OlsonSep 30, 2007
  5. Documentation/git-tag.txt: Document how to backdate tagsMichael Olson, Oct 15, 2007
  6. Jeff KingOct 15, 2007
  7. Michael OlsonOct 15, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.