From: Andy Parkins <andyparkins@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH 4/4] update-hook: allow for the possibility that a tagged object is not a commit
Date: Tue, 20 Mar 2007 10:58:47 +0000 [thread overview]
Message-ID: <200703201058.47485.andyparkins@gmail.com> (raw)
Tags are normally used to tag commits; however this isn't a requirement
so the update hook shouldn't assume it.
This patch only calculates the replacement tag if it is a commit tag -
non-commit tags don't represent a line of development so it would be
meaningless. Similarly, the short log is not shown for non-commit tags.
Signed-off-by: Andy Parkins <andyparkins@gmail.com>
---
templates/hooks--update | 30 ++++++++++++++++++++----------
1 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/templates/hooks--update b/templates/hooks--update
index fd4c081..cf2a31a 100644
--- a/templates/hooks--update
+++ b/templates/hooks--update
@@ -234,16 +234,20 @@ case "$refname_type" in
esac
done <<< "$(git cat-file tag $newrev | head -q -n 4)"
- # If this tag succeeds another, then show which tag it replaces
- prevtag=$(git describe --abbrev=0 $newrev^ 2>/dev/null)
- if [ -n "$prevtag" ]; then
- echo " replaces $prevtag"
- fi
-
# Extract user and time from tagger variable
eval $(sed -n 's/\([^>]*>\)[^0-9]*\([0-9]*\).*/tagger="\1" ts="\2"/p' <<< "$tagger")
tagged=$(date --date="1970-01-01 00:00:00 +0000 $ts seconds" +"$DATEFORMAT")
+ echo " tagging $tagobject ($tagtype)"
+ if [ "$tagtype" = "commit" ]; then
+ # If the tagged object is a commit, then we assume this is a
+ # release, and so we calculate which tag this tag is replacing
+ prevtag=$(git describe --abbrev=0 $newrev^ 2>/dev/null)
+
+ if [ -n "$prevtag" ]; then
+ echo " replaces $prevtag"
+ fi
+ fi
echo " tagged by $tagger"
echo " on $tagged"
@@ -257,10 +261,16 @@ case "$refname_type" in
git cat-file tag $newrev | tail -q -n +5
echo ""
- if [ -n "$prevtag" ]; then
- git rev-list --pretty=short "$prevtag..$newrev" | git shortlog
- else
- git rev-list --pretty=short $newrev | git shortlog
+ if [ "$tagtype" = "commit" ]; then
+ # Only commit tags make sense to have rev-list operations performed
+ # on them
+ if [ -n "$prevtag" ]; then
+ # Show changes since the previous release
+ git rev-list --pretty=short "$prevtag..$newrev" | git shortlog
+ else
+ # No previous tag, show all the changes since time began
+ git rev-list --pretty=short $newrev | git shortlog
+ fi
fi
echo $LOGEND
--
1.5.0.3.402.g0c48
reply other threads:[~2007-03-20 10:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200703201058.47485.andyparkins@gmail.com \
--to=andyparkins@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).