{"thread":{"id":"7330","subject":"[PATCH 4/4] update-hook: allow for the possibility that a tagged object is not a commit","startedAt":"2007-03-20T10:58:47Z","lastAt":"2007-03-20T10:58:47Z","messageCount":1,"participants":["Andy Parkins"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"37615","messageId":"200703201058.47485.andyparkins@gmail.com","threadId":"7330","inReplyTo":null,"subject":"[PATCH 4/4] update-hook: allow for the possibility that a tagged object is not a commit","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2007-03-20T10:58:47Z","receivedAt":"2007-03-20T10:58:47Z","isPatch":true,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"Tags are normally used to tag commits; however this isn't a requirement\nso the update hook shouldn't assume it.\n\nThis patch only calculates the replacement tag if it is a commit tag -\nnon-commit tags don't represent a line of development so it would be\nmeaningless.  Similarly, the short log is not shown for non-commit tags.\n\nSigned-off-by: Andy Parkins <andyparkins@gmail.com>\n---\n templates/hooks--update |   30 ++++++++++++++++++++----------\n 1 files changed, 20 insertions(+), 10 deletions(-)\n\ndiff --git a/templates/hooks--update b/templates/hooks--update\nindex fd4c081..cf2a31a 100644\n--- a/templates/hooks--update\n+++ b/templates/hooks--update\n@@ -234,16 +234,20 @@ case \"$refname_type\" in\n \t\t\tesac\n \t\tdone <<< \"$(git cat-file tag $newrev | head -q -n 4)\"\n \n-\t\t# If this tag succeeds another, then show which tag it replaces\n-\t\tprevtag=$(git describe --abbrev=0 $newrev^ 2>/dev/null)\n-\t\tif [ -n \"$prevtag\" ]; then\n-\t\t\techo \"  replaces  $prevtag\"\n-\t\tfi\n-\n \t\t# Extract user and time from tagger variable\n \t\teval $(sed -n 's/\\([^>]*>\\)[^0-9]*\\([0-9]*\\).*/tagger=\"\\1\" ts=\"\\2\"/p' <<< \"$tagger\")\n \t\ttagged=$(date --date=\"1970-01-01 00:00:00 +0000 $ts seconds\" +\"$DATEFORMAT\")\n \n+\t\techo \"   tagging  $tagobject ($tagtype)\"\n+\t\tif [ \"$tagtype\" = \"commit\" ]; then\n+\t\t\t# If the tagged object is a commit, then we assume this is a\n+\t\t\t# release, and so we calculate which tag this tag is replacing\n+\t\t\tprevtag=$(git describe --abbrev=0 $newrev^ 2>/dev/null)\n+\n+\t\t\tif [ -n \"$prevtag\" ]; then\n+\t\t\t\techo \"  replaces  $prevtag\"\n+\t\t\tfi\n+\t\tfi\n \t\techo \" tagged by  $tagger\"\n \t\techo \"        on  $tagged\"\n \n@@ -257,10 +261,16 @@ case \"$refname_type\" in\n \t\tgit cat-file tag $newrev | tail -q -n +5\n \n \t\techo \"\"\n-\t\tif [ -n \"$prevtag\" ]; then\n-\t\t\tgit rev-list --pretty=short \"$prevtag..$newrev\" | git shortlog\n-\t\telse\n-\t\t\tgit rev-list --pretty=short $newrev | git shortlog\n+\t\tif [ \"$tagtype\" = \"commit\" ]; then\n+\t\t\t# Only commit tags make sense to have rev-list operations performed\n+\t\t\t# on them\n+\t\t\tif [ -n \"$prevtag\" ]; then\n+\t\t\t\t# Show changes since the previous release\n+\t\t\t\tgit rev-list --pretty=short \"$prevtag..$newrev\" | git shortlog\n+\t\t\telse\n+\t\t\t\t# No previous tag, show all the changes since time began\n+\t\t\t\tgit rev-list --pretty=short $newrev | git shortlog\n+\t\t\tfi\n \t\tfi\n \n \t\techo $LOGEND\n-- \n1.5.0.3.402.g0c48\n"}]}