All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Olson <mwolson@gnu.org>
To: git@vger.kernel.org
Subject: Script to backdate tags
Date: Sat, 29 Sep 2007 23:16:32 -0400	[thread overview]
Message-ID: <87bqbklu5r.fsf@hariken.mwolson.org> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 533 bytes --]

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.


[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: git-backdate-tag --]
[-- Type: text/x-sh, Size: 763 bytes --]

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

[-- Attachment #3: Type: text/plain, Size: 255 bytes --]


-- 
       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 |

             reply	other threads:[~2007-09-30  3:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-30  3:16 Michael Olson [this message]
2007-09-30  4:29 ` Script to backdate tags Michael Olson
2007-09-30  5:16   ` Junio C Hamano
2007-09-30  6:27     ` Michael Olson
     [not found]       ` <7vd4w0iqd5.fsf@gitster.siamese.dyndns.org>
2007-10-15 17:51         ` [PATCH] Documentation/git-tag.txt: Document how " Michael Olson
2007-10-15 20:35           ` Jeff King
2007-10-15 22:53             ` Michael Olson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bqbklu5r.fsf@hariken.mwolson.org \
    --to=mwolson@gnu.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.