{"thread":{"id":"38383","subject":"Proper plumbing for porcelain gpg formats on git show?","startedAt":"2015-01-16T16:57:17Z","lastAt":"2015-01-19T14:13:34Z","messageCount":5,"participants":["Jason Pyeron","Jonathan Nieder","Junio C Hamano","Michael J Gruber"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"254817","messageId":"EB979B4B153D49909C78239A333869FB@black","threadId":"38383","inReplyTo":null,"subject":"Proper plumbing for porcelain gpg formats on git show?","fromName":"Jason Pyeron","fromEmail":"jpyeron@pdinc.us","sentAt":"2015-01-16T16:57:17Z","receivedAt":"2015-01-16T16:57:17Z","isPatch":false,"sender":{"key":"jpyeron@pdinc.us","avatar":"https://gravatar.com/avatar/c2e53452caa53d940768a1ffc9cf76196d851b9b534b7a39cd39852a70a0508f?d=mp&s=160"},"body":"I can't agree that \n\nCOMMITID=ef8df950c8d16dace62e55d18b26617b1268f1bc; \\\n git cat-file $COMMITID -p |\\\n sed -e '/^ /{H;$!d;}; x;/^gpgsig /!d; s/^gpgsig//;' |\\\n cut -c 2- |\\\n gpg --list-packets --textmode |\\\n sed '/keyid/!d; s/.*keyid \\([0-9A-F]\\{16\\}\\).*/\\1/I'\n\nis the way to go, when \n\nCOMMITID=ef8df950c8d16dace62e55d18b26617b1268f1bc; \\\n git log $COMMITID --pretty=format:%GK -n 1\n\nand\n\nCOMMITID=ef8df950c8d16dace62e55d18b26617b1268f1bc; \\\n git show $COMMITID --pretty=format:%GK -s\n\ndo the same thing.\n\nIs there a way to properly extract the GPG signature object, such that GPG operations may be done on it?\n\nAre the git log formats safe to use in scripts (asking because it was said not to use at http://git.661346.n2.nabble.com/show-pretty-B-without-a-diff-td5852061.html#a5853270)?\n\nIf git log with format specifiers is safe to use, would there be interest in accepting a patch for \n\n%Gs - the raw GPG text from the commit\n%Gf - the key fingerprint\n\n-Jason\n\n--\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n-                                                               -\n- Jason Pyeron                      PD Inc. http://www.pdinc.us -\n- Principal Consultant              10 West 24th Street #100    -\n- +1 (443) 269-1555 x333            Baltimore, Maryland 21218   -\n-                                                               -\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\nThis message is copyright PD Inc, subject to license 20080407P00.\n"},{"id":"254829","messageId":"20150116192947.GD29365@google.com","threadId":"38383","inReplyTo":"EB979B4B153D49909C78239A333869FB@black","subject":"Re: Proper plumbing for porcelain gpg formats on git show?","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2015-01-16T19:29:47Z","receivedAt":"2015-01-16T19:29:47Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nJason Pyeron wrote:\n\n> COMMITID=ef8df950c8d16dace62e55d18b26617b1268f1bc; \\\n>  git show $COMMITID --pretty=format:%GK -s\n>\n> do the same thing.\n>\n> Is there a way to properly extract the GPG signature object, such\n> that GPG operations may be done on it?\n>\n> Are the git log formats safe to use in scripts (asking because it\n> was said not to use at\n> http://git.661346.n2.nabble.com/show-pretty-B-without-a-diff-td5852061.html#a5853270)?\n\nBetter to use\n\n\tgit diff-tree -s --always --format=%GK $COMMITID\n\n[...]\n> would there be interest in accepting a patch for \n>\n> %Gs - the raw GPG text from the commit\n> %Gf - the key fingerprint\n\nThere may be bikeshedding on the exact format specifier, but aside\nfrom that I don't see why not. ;-)\n\nThanks,\nJonathan\n"},{"id":"254834","messageId":"xmqqk30m1p0t.fsf@gitster.dls.corp.google.com","threadId":"38383","inReplyTo":"20150116192947.GD29365@google.com","subject":"Re: Proper plumbing for porcelain gpg formats on git show?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-01-16T19:52:50Z","receivedAt":"2015-01-16T19:52:50Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n>> would there be interest in accepting a patch for \n>>\n>> %Gs - the raw GPG text from the commit\n>> %Gf - the key fingerprint\n>\n> There may be bikeshedding on the exact format specifier, but aside\n> from that I don't see why not. ;-)\n\nI was about to say \"As long as the execution is good, why not?\nSpawning an extra process 'gpg --list-packets' is not quite\nacceptable without properly being lazy is not acceptable\".\n\nBut verify_signed_buffer() reads \"gpg --status-fd=1 --verify\"\noutput, it is already done lazily in format_commit_one() only when\nthe \"%G?\" placeholder is used, and the output we parse that are\nprefixed by [GNUPG:] should have enough information to grab the\nfingerprint from on the VALIDSIG line.\n\nSo I do not see a lot of room to screw-up the execution ;-).\n"},{"id":"254837","messageId":"6B1E582B25CD4722B8993C5A3C304ECA@black","threadId":"38383","inReplyTo":"xmqqk30m1p0t.fsf@gitster.dls.corp.google.com","subject":"RE: Proper plumbing for porcelain gpg formats on git show?","fromName":"Jason Pyeron","fromEmail":"jpyeron@pdinc.us","sentAt":"2015-01-16T20:05:00Z","receivedAt":"2015-01-16T20:05:00Z","isPatch":false,"sender":{"key":"jpyeron@pdinc.us","avatar":"https://gravatar.com/avatar/c2e53452caa53d940768a1ffc9cf76196d851b9b534b7a39cd39852a70a0508f?d=mp&s=160"},"body":"> -----Original Message-----\n> From: Junio C Hamano\n> Sent: Friday, January 16, 2015 14:53\n> \n> Jonathan Nieder <jrnieder@gmail.com> writes:\n> \n> >> would there be interest in accepting a patch for \n> >>\n> >> %Gs - the raw GPG text from the commit\n> >> %Gf - the key fingerprint\n> >\n> > There may be bikeshedding on the exact format specifier, but aside\n> > from that I don't see why not. ;-)\n> \n> I was about to say \"As long as the execution is good, why not?\n> Spawning an extra process 'gpg --list-packets' is not quite\n> acceptable without properly being lazy is not acceptable\".\n> \n> But verify_signed_buffer() reads \"gpg --status-fd=1 --verify\"\n> output, it is already done lazily in format_commit_one() only when\n> the \"%G?\" placeholder is used, and the output we parse that are\n> prefixed by [GNUPG:] should have enough information to grab the\n> fingerprint from on the VALIDSIG line.\n> \n> So I do not see a lot of room to screw-up the execution ;-).\n\nThis kind of begs the question of extracting signatures, not in one's keyring. I was surprised to see %GK fail because it was not yet in the keyring. I would also expect a \"B\", not a \"N\" for %G?, maybe there should be a \"X\" for can't verify.\n\n$ gpg --delete-keys DA0848AD\ngpg (GnuPG) 2.0.14; Copyright (C) 2009 Free Software Foundation, Inc.\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n\n\npub  2048R/DA0848AD 2014-06-24 Jason Pyeron <jpyeron@pdinc.us>\n\nDelete this key from the keyring? (y/N) y\n\n$ git diff-tree -s --format=%G? HEAD\nN\n\n$ git diff-tree -s --format=%GG HEAD\ngpg: Signature made Fri 16 Jan 2015 01:33:12 PM EST using RSA key ID DA0848AD\ngpg: Can't check signature: No public key\n\n\n$ git diff-tree -s --format=%GK HEAD\n\n$ gpg --keyserver hkp://pgp.mit.edu --recv-keys 8D6B5984DA0848AD\ngpg: requesting key DA0848AD from hkp server pgp.mit.edu\ngpg: key DA0848AD: public key \"Jason Pyeron <jpyeron@pdinc.us>\" imported\ngpg: Total number processed: 1\ngpg:               imported: 1  (RSA: 1)\n\n$ git diff-tree -s --format=%G? HEAD\nU\n\n$ git diff-tree -s --format=%GG HEAD\ngpg: Signature made Fri 16 Jan 2015 01:33:12 PM EST using RSA key ID DA0848AD\ngpg: Good signature from \"Jason Pyeron <jpyeron@pdinc.us>\"\ngpg: WARNING: This key is not certified with a trusted signature!\ngpg:          There is no indication that the signature belongs to the owner.\nPrimary key fingerprint: 8C88 9ECF 7A2F 7977 7CE9  13B4 8D6B 5984 DA08 48AD\n\n\n$ git diff-tree -s --format=%GK HEAD\n8D6B5984DA0848AD\n\n\n\n--\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n-                                                               -\n- Jason Pyeron                      PD Inc. http://www.pdinc.us -\n- Principal Consultant              10 West 24th Street #100    -\n- +1 (443) 269-1555 x333            Baltimore, Maryland 21218   -\n-                                                               -\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\nThis message is copyright PD Inc, subject to license 20080407P00. \n"},{"id":"254878","messageId":"54BD110E.2080801@drmicha.warpmail.net","threadId":"38383","inReplyTo":"6B1E582B25CD4722B8993C5A3C304ECA@black","subject":"Re: Proper plumbing for porcelain gpg formats on git show?","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2015-01-19T14:13:34Z","receivedAt":"2015-01-19T14:13:34Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Jason Pyeron schrieb am 16.01.2015 um 21:05:\n>> -----Original Message-----\n>> From: Junio C Hamano\n>> Sent: Friday, January 16, 2015 14:53\n>>\n>> Jonathan Nieder <jrnieder@gmail.com> writes:\n>>\n>>>> would there be interest in accepting a patch for \n>>>>\n>>>> %Gs - the raw GPG text from the commit\n>>>> %Gf - the key fingerprint\n>>>\n>>> There may be bikeshedding on the exact format specifier, but aside\n>>> from that I don't see why not. ;-)\n>>\n>> I was about to say \"As long as the execution is good, why not?\n>> Spawning an extra process 'gpg --list-packets' is not quite\n>> acceptable without properly being lazy is not acceptable\".\n>>\n>> But verify_signed_buffer() reads \"gpg --status-fd=1 --verify\"\n>> output, it is already done lazily in format_commit_one() only when\n>> the \"%G?\" placeholder is used, and the output we parse that are\n>> prefixed by [GNUPG:] should have enough information to grab the\n>> fingerprint from on the VALIDSIG line.\n>>\n>> So I do not see a lot of room to screw-up the execution ;-).\n> \n> This kind of begs the question of extracting signatures, not in one's keyring. I was surprised to see %GK fail because it was not yet in the keyring. I would also expect a \"B\", not a \"N\" for %G?, maybe there should be a \"X\" for can't verify.\n> \n> $ gpg --delete-keys DA0848AD\n> gpg (GnuPG) 2.0.14; Copyright (C) 2009 Free Software Foundation, Inc.\n> This is free software: you are free to change and redistribute it.\n> There is NO WARRANTY, to the extent permitted by law.\n> \n> \n> pub  2048R/DA0848AD 2014-06-24 Jason Pyeron <jpyeron@pdinc.us>\n> \n> Delete this key from the keyring? (y/N) y\n> \n> $ git diff-tree -s --format=%G? HEAD\n> N\n> \n> $ git diff-tree -s --format=%GG HEAD\n> gpg: Signature made Fri 16 Jan 2015 01:33:12 PM EST using RSA key ID DA0848AD\n> gpg: Can't check signature: No public key\n> \n> \n> $ git diff-tree -s --format=%GK HEAD\n> \n> $ gpg --keyserver hkp://pgp.mit.edu --recv-keys 8D6B5984DA0848AD\n> gpg: requesting key DA0848AD from hkp server pgp.mit.edu\n> gpg: key DA0848AD: public key \"Jason Pyeron <jpyeron@pdinc.us>\" imported\n> gpg: Total number processed: 1\n> gpg:               imported: 1  (RSA: 1)\n> \n> $ git diff-tree -s --format=%G? HEAD\n> U\n> \n> $ git diff-tree -s --format=%GG HEAD\n> gpg: Signature made Fri 16 Jan 2015 01:33:12 PM EST using RSA key ID DA0848AD\n> gpg: Good signature from \"Jason Pyeron <jpyeron@pdinc.us>\"\n> gpg: WARNING: This key is not certified with a trusted signature!\n> gpg:          There is no indication that the signature belongs to the owner.\n> Primary key fingerprint: 8C88 9ECF 7A2F 7977 7CE9  13B4 8D6B 5984 DA08 48AD\n> \n> \n> $ git diff-tree -s --format=%GK HEAD\n> 8D6B5984DA0848AD\n\nI'm not exactly sure what you are trying to extract, but \"git\nverify-commit -v\" gives you the actual signature, which you can then\nfeed into gpg/gpgsplit for surgery according to taste.\n\nAs far as git goes, I think it should give you all gpg information that\nit has available but not morph into a gpg frontend or trust manager.\n\nUltimately, signature verification in its true meaning requires human\ninspection of the full gpg output.\n\nMichael\n"}]}