{"thread":{"id":"13066","subject":"backdated tag bug","startedAt":"2008-04-11T20:28:32Z","lastAt":"2008-04-11T20:54:51Z","messageCount":4,"participants":["Eric Blake","Linus Torvalds","Björn Steinbrink"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"74141","messageId":"loom.20080411T193913-700@post.gmane.org","threadId":"13066","inReplyTo":null,"subject":"backdated tag bug","fromName":"Eric Blake","fromEmail":"ebb9@byu.net","sentAt":"2008-04-11T20:28:32Z","receivedAt":"2008-04-11T20:28:32Z","isPatch":false,"sender":{"key":"eblake@redhat.com","avatar":"https://avatars.githubusercontent.com/u/32933908?v=4"},"body":"According to 'git tag --help', it should be possible to create a signed, back-\ndated tag.  But I can't get it to work.  Am I doing something wrong, or is this \na git bug?  Shell transcript follows:\n\n# Done on a demo repository, although I encountered the bug on a real one.\n# I plan on creating two revisions, then tagging the first v1 OLDER than\n# the second at v2\n\n$ mkdir foo\n$ cd foo\n$ git --version\ngit version 1.5.5\n$ git init\nInitialized empty Git repository in .git/\n$ echo hi > file\n$ git add file\n$ git commit -m commit1\nCreated initial commit 617ff6a: commit1\n 1 files changed, 1 insertions(+), 0 deletions(-)\n create mode 100644 file\n$ echo bye > file\n$ git commit -a -m commit2\nCreated commit 3f226cf: commit2\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\n# Create a tag right now, for comparison purposes\n\n$ git tag -s v2 -m v2  \n\nYou need a passphrase to unlock the secret key for\nuser: \"Eric Blake (free software programmer) <ebb9@byu.net>\"\n1024-bit DSA key, ID F4850180, created 2004-12-18\n\n$ git cat-file tag v2\nobject 3f226cf9b3905b60310866ab7a72c744f0f1feb4\ntype commit\ntag v2\ntagger Eric Blake <ebb9@byu.net> 1207943097 -0600\n\nv2\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1.4.9 (Cygwin)\nComment: Public key at home.comcast.net/~ericblake/eblake.gpg\n\niEYEABECAAYFAkf/v7kACgkQ84KuGfSFAYA4ygCcDwGYnyWBanfQyZPInKrMluYu\nm4AAnjQi/TQ+14MDtBeo3MrrpSQXoJnN\n=HAcH\n-----END PGP SIGNATURE-----\n\n# Make sure I know how to get an older date\n\n$ date '+%F %R'\n2008-04-11 13:47\n$ date '+%F %R' -d '-1 day'\n2008-04-10 13:47\n\n# Now, follow the advice in 'git tag --help'\n\n$ GIT_AUTHOR_DATE=`date '+%F %R' -d '-1 day'` git tag -s v1 -m v1 HEAD^\n\nYou need a passphrase to unlock the secret key for\nuser: \"Eric Blake (free software programmer) <ebb9@byu.net>\"\n1024-bit DSA key, ID F4850180, created 2004-12-18\n\n$ git cat-file tag v1\nobject 617ff6a0daf5b9a32732bb79ef98f2abd3cd58de\ntype commit\ntag v1\ntagger Eric Blake <ebb9@byu.net> 1207943332 -0600\n\nv1\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1.4.9 (Cygwin)\nComment: Public key at home.comcast.net/~ericblake/eblake.gpg\n\niEYEABECAAYFAkf/wKQACgkQ84KuGfSFAYBGKACfdWzVMRgaLZImxj8IMMEDDOZr\nz38An2WotiiskR+uXaIVglR6zX0mYFGD\n=WEKw\n-----END PGP SIGNATURE-----\n\n# Hey wait a minute - 1207943097 is older than 1207943332.\n# Which means v1 wasn't back-dated the way I asked :(\n# Just to double-check with some human-readable times...\n\n$ git tag -v v1 v2 2>&1 | grep -B1 made\nv1\ngpg: Signature made Fri Apr 11 13:48:52 2008 MDT using DSA key ID F4850180\n--\nv2\ngpg: Signature made Fri Apr 11 13:44:57 2008 MDT using DSA key ID F4850180\n\n# Oh well, I give up - 'git tag --help' lied about creating signed back-dated\n# annotated tags. Since the porcelain didn't work, I'll try the plumbing.\n\n$ git tag -d v1\nDeleted tag 'v1'\n$ emacs t\n$ cat t\nobject 617ff6a0daf5b9a32732bb79ef98f2abd3cd58de\ntype commit\ntag v1\ntagger Eric Blake <ebb9@byu.net> `date +%s -d '-1 day'` -0600\n\nv1\n$ echo `git mktag < t` > .git/refs/tags/v1\n$ git show v1 | head\ntag v1\nTagger: Eric Blake <ebb9@byu.net>\nDate:   Thu Apr 10 14:02:15 2008 -0600\n\nv1\ncommit 617ff6a0daf5b9a32732bb79ef98f2abd3cd58de\nAuthor: Eric Blake <ebb9@byu.net>\nDate:   Fri Apr 11 13:40:17 2008 -0600\n\n    commit1\n\n# Better than nothing - I created a valid, annotated, back-dated tag.  But it\n# isn't signed.  So let's try again:\n\n$ gpg --clearsign t\n\nYou need a passphrase to unlock the secret key for\nuser: \"Eric Blake (free software programmer) <ebb9@byu.net>\"\n1024-bit DSA key, ID F4850180, created 2004-12-18\n\n$ echo `git mktag < t.asc` > .git/refs/tags/v1\nerror: char0: does not start with \"object \"\nfatal: invalid tag signature file\n\n# The plumbing doesn't like the BEGIN PGP SIGNED line, so I'll just strip it:\n\n$ echo `tail -n+4 t.asc | git mktag` > .git/refs/tags/v1\n$ git show v1 | head -n15\ntag v1\nTagger: Eric Blake <ebb9@byu.net>\nDate:   Thu Apr 10 14:02:15 2008 -0600\n\nv1\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1.4.9 (Cygwin)\nComment: Public key at home.comcast.net/~ericblake/eblake.gpg\n\niEYEARECAAYFAkf/xIMACgkQ84KuGfSFAYC8egCfZAFQ5LSnUPELCjifsr1DQKrE\nPCUAoIGzd6pApwZNaaHuhO6miggycF1d\n=qCJn\n-----END PGP SIGNATURE-----\ncommit 617ff6a0daf5b9a32732bb79ef98f2abd3cd58de\nAuthor: Eric Blake <ebb9@byu.net>\n\n# There.  That worked - a back-dated signed tag!  Or did it?\n\n$ git tag -v v1\nobject 617ff6a0daf5b9a32732bb79ef98f2abd3cd58de\ntype commit\ntag v1\ntagger Eric Blake <ebb9@byu.net> 1207857735 -0600\n\nv1\ngpg: Signature made Fri Apr 11 14:05:23 2008 MDT using DSA key ID F4850180\ngpg: BAD signature from \"Eric Blake (free software programmer) <ebb9@byu.net>\"\nerror: could not verify the tag 'v1'\n\n# Shoot.  I got the signature wrong.  The help on 'git mktag --help' mentions\n# that tags can be signed, but *does not say how to use gpg to get to that\n# point*.  I suppose I could read the source code, but I really expected that\n# the manual would tell me how.  On the other hand, I guess I can live with\n# leaving the 'git mktag' documentation alone if the original 'git tag' bug\n# is fixed.\n\n# Side note - while investigating this, I found another instance where the\n# ui could be improved.  Compare the difference between annotated and\n# lightweight tags:\n\n$ git tag -m v3 v3\n$ git tag v4\n$ git tag -v v3\nobject 3f226cf9b3905b60310866ab7a72c744f0f1feb4\ntype commit\ntag v3\ntagger Eric Blake <ebb9@byu.net> 1207945051 -0600\n\nv3\ngpg: no valid OpenPGP data found.\ngpg: the signature could not be verified.\nPlease remember that the signature file (.sig or .asc)\nshould be the first file given on the command line.\nerror: could not verify the tag 'v3'\n\n# Why'd we get all the way to gpg?  Shouldn't git be smart enough to realize\n# that there is no 'BEGIN PGP SIGNATURE', and not waste the time calling gpg?\n\n$ git tag -v v4\nerror: 3f226cf9b3905b60310866ab7a72c744f0f1feb4: cannot verify a non-tag object \nof type commit.\nerror: could not verify the tag 'v4'\n\n# Make up your mind.  Is v4 \"a non-tag object\" or \"tag 'v4'\"?  I think it\n# would be nicer if git could tell me something like:\nerror: tag 'v3' is not signed\nerror: tag 'v4' is not annotated or signed\n\n-- \nEric Blake\n"},{"id":"74143","messageId":"alpine.LFD.1.00.0804111333270.3143@woody.linux-foundation.org","threadId":"13066","inReplyTo":"loom.20080411T193913-700@post.gmane.org","subject":"Re: backdated tag bug","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2008-04-11T20:36:04Z","receivedAt":"2008-04-11T20:36:04Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Fri, 11 Apr 2008, Eric Blake wrote:\n>\n> According to 'git tag --help', it should be possible to create a signed, back-\n> dated tag.  But I can't get it to work.  Am I doing something wrong, or is this \n> a git bug?  Shell transcript follows:\n\nTags don't have an \"author\". They have a \"tagger\", and it's taken from the \nnormal committer information. So you should use GIT_COMMITTER_DATE instead \nof GIT_AUTHOR_DATE and it should work.\n\n\t\tLinus\n"},{"id":"74144","messageId":"20080411205207.GA18531@atjola.homenet","threadId":"13066","inReplyTo":"loom.20080411T193913-700@post.gmane.org","subject":"[PATCH] Fix section about backdating tags in the git-tag docs","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-04-11T20:52:07Z","receivedAt":"2008-04-11T20:52:07Z","isPatch":true,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"The tagger is equal to the committer, not the author, so\nGIT_COMMITTER_DATE is the right environment variable to use, not\nGIT_AUTHOR_DATE.\n\nSigned-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>\n---\n Documentation/git-tag.txt |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt\nindex 4b6fd90..9712392 100644\n--- a/Documentation/git-tag.txt\n+++ b/Documentation/git-tag.txt\n@@ -233,14 +233,14 @@ the tag object affects, for example, the ordering of tags in the\n gitweb interface.\n \n To set the date used in future tag objects, set the environment\n-variable GIT_AUTHOR_DATE to one or more of the date and time.  The\n+variable GIT_COMMITTER_DATE to one or more of the date and time.  The\n date and time can be specified in a number of ways; the most common\n is \"YYYY-MM-DD HH:MM\".\n \n An example follows.\n \n ------------\n-$ GIT_AUTHOR_DATE=\"2006-10-02 10:31\" git tag -s v1.0.1\n+$ GIT_COMMITTER_DATE=\"2006-10-02 10:31\" git tag -s v1.0.1\n ------------\n \n \n-- \n1.5.5.rc3.7.gba133\n"},{"id":"74145","messageId":"loom.20080411T204008-458@post.gmane.org","threadId":"13066","inReplyTo":"alpine.LFD.1.00.0804111333270.3143@woody.linux-foundation.org","subject":"Re: backdated tag bug","fromName":"Eric Blake","fromEmail":"ebb9@byu.net","sentAt":"2008-04-11T20:54:51Z","receivedAt":"2008-04-11T20:54:51Z","isPatch":false,"sender":{"key":"eblake@redhat.com","avatar":"https://avatars.githubusercontent.com/u/32933908?v=4"},"body":"Linus Torvalds <torvalds <at> linux-foundation.org> writes:\n\n> > According to 'git tag --help', it should be possible to create a signed, \nback-\n> > dated tag.  But I can't get it to work.  Am I doing something wrong, or is \nthis \n> > a git bug?  Shell transcript follows:\n> \n> Tags don't have an \"author\". They have a \"tagger\", and it's taken from the \n> normal committer information. So you should use GIT_COMMITTER_DATE instead \n> of GIT_AUTHOR_DATE and it should work.\n\nThanks.  At first, I thought it failed: the only human-readable date string in \nthe output of 'git tag -v v1' was the date of the gpg signature, which was of \ncourse today.  But on closer inspection, the raw seconds listing in the tagger \nline was indeed older, and 'git show v1' shows the desired human-readable back-\ndate of yesterday.  So, can we get the 'git tag' documentation fixed to mention \nGIT_COMMITTER_DATE, and can 'git tag -v' be improved to show the tagger date in \nhuman-readable form?\n\nAnd I still think it would be nice if 'git mktag --help' mentioned how to use \ngpg to create a valid signed tag, rather than just vaguely stating that it can \nbe done, since I couldn't figure out how to create a tag signature file that \nwould pass subsequent verification.\n\n-- \nEric Blake\n"}]}