<oembed><type>rich</type><version>1.0</version><author_name>npub16dt55fpq3a8r6zpphd9xngxr46zzqs75gna9cj5vf8pknyv2d7equx4wrd</author_name><author_url>https://nostr.ae/npub16dt55fpq3a8r6zpphd9xngxr46zzqs75gna9cj5vf8pknyv2d7equx4wrd</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2014-05-21&#xA;📝 Original message:On Wed, May 21, 2014 at 06:39:44PM +0200, Chris Beams wrote:&#xA;&gt; I [was] searching for a way to enable signing by default [...]&#xA;&gt; Unfortunately, there isn&#39;t one, meaning it&#39;s likely that most folks&#xA;&gt; will forget to do this most of the time.&#xA;&#xA;For all of my projects, I now I put this script in&#xA;.git/hooks/post-commit and post-merge:&#xA;&#xA;    #!/bin/bash -eu&#xA;&#xA;    if ! git log -n1 --show-signature | grep -q &#39;gpg: Good signature&#39;&#xA;    then&#xA;        yes &#34;FORGOT TO SIGN COMMIT MESSAGE&#34;&#xA;        exit 1&#xA;    fi&#xA;&#xA;So anytime I forget to sign, I get an obvious error and can immediately&#xA;run git commit --amend -S.&#xA;&#xA;To automatically add a script like the one above to all new projects (plus&#xA;quickly add it old current projects), you can follow these instructions:&#xA;&#xA;    http://stackoverflow.com/questions/2293498/git-commit-hooks-global-settings&#xA;&#xA;&gt; If you&#39;re really serious about it, you should probably reject pull&#xA;&gt; requests without signed commits; otherwise, signing becomes&#xA;&gt; meaningless because only honest authors do it&#xA;&#xA;I find signing my commits quite useful even on projects without a&#xA;default signing policy because it lets me diff from the last time I&#xA;provably reviewed the code.  Here&#39;s my script for that:&#xA;&#xA;    #!/bin/bash -eu&#xA;&#xA;    KEY=F29EC4B7&#xA;&#xA;    last_signed_commit=$( git log --topo-order --show-signature --pretty=oneline \&#xA;        | grep -m1 &#34; gpg: Signature made.*RSA key ID $KEY&#34; \&#xA;        | sed &#39;s/ .*//&#39; \&#xA;        | grep .&#xA;    ) || { echo &#34;No signed commit found.  Dying...&#34; ; exit 1 ; }&#xA;&#xA;    set -x&#xA;    git diff $last_signed_commit&#xA;&#xA;By diffing against the last signed commit I made, I also review any&#xA;commits that were made using my name but which I didn&#39;t actually make,&#xA;such as squashes and rebases of my commits (and, of course, forgeries).&#xA;&#xA;For anyone who&#39;s bored and wants to read a lot of text, I think the&#xA;definitive work on git signing is this:&#xA;&#xA;    http://mikegerwitz.com/papers/git-horror-story.html&#xA;&#xA;-Dave&#xA;-- &#xA;David A. Harding</html></oembed>