* [PATCH 4/4] update-hook: allow for the possibility that a tagged object is not a commit
@ 2007-03-20 10:58 Andy Parkins
0 siblings, 0 replies; only message in thread
From: Andy Parkins @ 2007-03-20 10:58 UTC (permalink / raw)
To: git
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2007-03-20 10:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-20 10:58 [PATCH 4/4] update-hook: allow for the possibility that a tagged object is not a commit Andy Parkins
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).