summaryrefslogtreecommitdiff
path: root/93/10a5a41902c13a9d751ca837b56a5c6a58d6c3
blob: 6f56e0bb4f75282d99754ed425d3d31a87dd1826 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192]
	helo=mx.sourceforge.net)
	by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76)
	(envelope-from <chris@beams.io>) id 1WnHW8-0002qU-TR
	for bitcoin-development@lists.sourceforge.net;
	Thu, 22 May 2014 01:09:56 +0000
X-ACL-Warn: 
Received: from chello084114181075.1.15.vie.surfer.at ([84.114.181.75]
	helo=dh35.beams.io) by sog-mx-2.v43.ch3.sourceforge.com with esmtp 
	(Exim 4.76) id 1WnHW6-0000p9-Ts
	for bitcoin-development@lists.sourceforge.net;
	Thu, 22 May 2014 01:09:56 +0000
Received: from localhost (localhost [127.0.0.1])
	by dh35.beams.io (Postfix) with ESMTP id 51980201407;
	Thu, 22 May 2014 03:09:48 +0200 (CEST)
X-Virus-Scanned: amavisd-new at dh35.beams.io
Received: from dh35.beams.io ([127.0.0.1])
	by localhost (dh35.beams.io [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id Qsshkxj-8YG0; Thu, 22 May 2014 03:09:38 +0200 (CEST)
Received: from [192.168.0.69] (chello084114181075.1.15.vie.surfer.at
	[84.114.181.75])
	by dh35.beams.io (Postfix) with ESMTPSA id 97B882013DF;
	Thu, 22 May 2014 03:09:38 +0200 (CEST)
Content-Type: multipart/signed;
	boundary="Apple-Mail=_23EB31E1-FF71-4D75-A5B5-B73B17931285";
	protocol="application/pgp-signature"; micalg=pgp-sha512
Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.2\))
From: Chris Beams <chris@beams.io>
In-Reply-To: <20140521202502.GA439@localhost.localdomain>
Date: Thu, 22 May 2014 03:09:35 +0200
Message-Id: <D60239BA-5329-463F-9870-7B28661E9581@beams.io>
References: <CA+s+GJBNWh0Py9KB4Y+B19ACeHOygtkLrPw5SbZ0SrVs50pqvg@mail.gmail.com>
	<7B48B9D4-5FB0-42CA-A462-C20D3F345A9A@beams.io>
	<20140521202502.GA439@localhost.localdomain>
To: "David A. Harding" <dave@dtrt.org>
X-Mailer: Apple Mail (2.1878.2)
X-Spam-Score: 1.0 (+)
X-Spam-Report: Spam Filtering performed by mx.sourceforge.net.
	See http://spamassassin.org/tag/ for more details.
	0.0 RCVD_IN_SORBS_DUL RBL: SORBS: sent directly from dynamic IP address
	[84.114.181.75 listed in dnsbl.sorbs.net]
	1.0 HTML_MESSAGE           BODY: HTML included in message
X-Headers-End: 1WnHW6-0000p9-Ts
Cc: Bitcoin Dev <bitcoin-development@lists.sourceforge.net>
Subject: Re: [Bitcoin-development] PSA: Please sign your git commits
X-BeenThere: bitcoin-development@lists.sourceforge.net
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: <bitcoin-development.lists.sourceforge.net>
List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/bitcoin-development>,
	<mailto:bitcoin-development-request@lists.sourceforge.net?subject=unsubscribe>
List-Archive: <http://sourceforge.net/mailarchive/forum.php?forum_name=bitcoin-development>
List-Post: <mailto:bitcoin-development@lists.sourceforge.net>
List-Help: <mailto:bitcoin-development-request@lists.sourceforge.net?subject=help>
List-Subscribe: <https://lists.sourceforge.net/lists/listinfo/bitcoin-development>,
	<mailto:bitcoin-development-request@lists.sourceforge.net?subject=subscribe>
X-List-Received-Date: Thu, 22 May 2014 01:09:57 -0000


--Apple-Mail=_23EB31E1-FF71-4D75-A5B5-B73B17931285
Content-Type: multipart/alternative;
	boundary="Apple-Mail=_AE7156A4-A359-42BB-AF9D-8D265DC91E11"


--Apple-Mail=_AE7156A4-A359-42BB-AF9D-8D265DC91E11
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii


On May 21, 2014, at 10:25 PM, David A. Harding <dave@dtrt.org> wrote:

> On Wed, May 21, 2014 at 06:39:44PM +0200, Chris Beams wrote:
>> I [was] searching for a way to enable signing by default [...]
>> Unfortunately, there isn't one, meaning it's likely that most folks
>> will forget to do this most of the time.
>=20
> For all of my projects, I now I put this script in
> .git/hooks/post-commit and post-merge:
>=20
>    #!/bin/bash -eu
>=20
>    if ! git log -n1 --show-signature | grep -q 'gpg: Good signature'
>    then
>        yes "FORGOT TO SIGN COMMIT MESSAGE"
>        exit 1
>    fi

Funny, I was just in the middle of writing a pre-push hook to do =
something similar when I decided to check my email :) Your post-commit =
approach is indeed simpler, so I've gone with it for the moment [1]. =
Thanks.

However, I noticed in the process of testing that this approach messes =
with rebase workflows. For example: if I make several commits (all of =
which are properly signed), and then rebase to reorder them, rebase ends =
up hanging because it delegates to `commit` and the use of `yes` in the =
post-commit hook blocks forever. I've changed `yes` to `echo` to avoid =
this, but it still means that one must be rather diligent to keep =
signatures in place when rebasing. Gerwitz does address rebasing in the =
presence of commit sigs in the "horror story" doc you linked to [2], but =
there's no magic: this makes the whole rebasing process considerably =
more tedious, and linearly so with however many commits you're =
modifying.

This may amount to a rationale for going with a pre-push hook after all, =
i.e. in order to defer the check for signatures until the last possible =
moment. This would allow for cheap iterative rebasing once again.

I suppose the proper solution would be a `git config` option such as =
'commit.sign', that if set to true would mean your commits are always =
signed, even if rebase is the one calling `commit`. This would obviate =
the need for the alias I mention below as well.


> So anytime I forget to sign, I get an obvious error and can =
immediately
> run git commit --amend -S.

If one is already in the habit of using an alias for `commit` (I've long =
used `ci` for concision), the -S can be included in the alias:

    git config alias.ci 'commit -S'


> To automatically add a script like the one above to all new projects =
(plus
> quickly add it old current projects), you can follow these =
instructions:
>=20
>    =
http://stackoverflow.com/questions/2293498/git-commit-hooks-global-setting=
s

This was a great tip, thanks!

- Chris

[1]: https://github.com/cbeams/dotfiles/commit/58d6942
[2]: http://mikegerwitz.com/papers/git-horror-story.html#_option_3

--Apple-Mail=_AE7156A4-A359-42BB-AF9D-8D265DC91E11
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=us-ascii

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html =
charset=3Dus-ascii"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; -webkit-line-break: =
after-white-space;"><div><br></div><div><div><div>On May 21, 2014, at =
10:25 PM, David A. Harding &lt;<a =
href=3D"mailto:dave@dtrt.org">dave@dtrt.org</a>&gt; wrote:</div><br =
class=3D"Apple-interchange-newline"><blockquote type=3D"cite">On Wed, =
May 21, 2014 at 06:39:44PM +0200, Chris Beams wrote:<br><blockquote =
type=3D"cite">I [was] searching for a way to enable signing by default =
[...]<br>Unfortunately, there isn't one, meaning it's likely that most =
folks<br>will forget to do this most of the =
time.<br></blockquote><br>For all of my projects, I now I put this =
script in<br>.git/hooks/post-commit and post-merge:<br><br> =
&nbsp;&nbsp;&nbsp;#!/bin/bash -eu<br><br> &nbsp;&nbsp;&nbsp;if ! git log =
-n1 --show-signature | grep -q 'gpg: Good signature'<br> =
&nbsp;&nbsp;&nbsp;then<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;yes =
"FORGOT TO SIGN COMMIT MESSAGE"<br> =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit 1<br> =
&nbsp;&nbsp;&nbsp;fi<br></blockquote><div><br></div><div>Funny, I was =
just in the middle of writing a pre-push hook to do something similar =
when I decided to check my email :) Your post-commit approach is indeed =
simpler, so I've gone with it for the moment [1]. =
Thanks.</div><div><br></div><div>However, I noticed in the process of =
testing that this approach messes with rebase workflows. For example: if =
I make several commits (all of which are properly signed), and then =
rebase to reorder them, rebase ends up hanging because it delegates to =
`commit` and the use of `yes` in the post-commit hook blocks forever. =
I've changed `yes` to `echo` to avoid this, but it still means that one =
must be rather diligent to keep signatures in place when rebasing. =
Gerwitz does address rebasing in the presence of commit sigs in the =
"horror story" doc you linked to [2], but there's no magic: this makes =
the whole rebasing process considerably more tedious, and linearly so =
with however many commits you're =
modifying.</div><div><br></div><div>This may amount to a rationale for =
going with a pre-push hook after all, i.e. in order to defer the check =
for signatures until the last possible moment. This would allow for =
cheap iterative rebasing once again.</div><div><br></div><div>I suppose =
the proper solution would be a `git config` option such as =
'commit.sign', that if set to true would mean your commits are always =
signed, even if rebase is the one calling `commit`. This would obviate =
the need for the alias I mention below as =
well.</div><div><br></div><div><br></div><blockquote type=3D"cite">So =
anytime I forget to sign, I get an obvious error and can =
immediately<br>run git commit --amend =
-S.<br></blockquote><div><br></div><div>If one is already in the habit =
of using an alias for `commit` (I've long used `ci` for concision), the =
-S can be included in the alias:</div><div><br></div><div>&nbsp; =
&nbsp;&nbsp;git config alias.ci 'commit =
-S'</div><div><br></div><div><div><br></div></div><blockquote =
type=3D"cite">To automatically add a script like the one above to all =
new projects (plus<br>quickly add it old current projects), you can =
follow these instructions:<br><br> &nbsp;&nbsp;&nbsp;<a =
href=3D"http://stackoverflow.com/questions/2293498/git-commit-hooks-global=
-settings">http://stackoverflow.com/questions/2293498/git-commit-hooks-glo=
bal-settings</a><br></blockquote></div><br></div><div>This was a great =
tip, thanks!</div><div><br></div><div>- =
Chris</div><div><div><div><br></div><div>[1]:&nbsp;<a =
href=3D"https://github.com/cbeams/dotfiles/commit/58d6942">https://github.=
com/cbeams/dotfiles/commit/58d6942</a></div><div>[2]:&nbsp;<a =
href=3D"http://mikegerwitz.com/papers/git-horror-story.html#_option_3">htt=
p://mikegerwitz.com/papers/git-horror-story.html#_option_3</a></div></div>=
</div></body></html>=

--Apple-Mail=_AE7156A4-A359-42BB-AF9D-8D265DC91E11--

--Apple-Mail=_23EB31E1-FF71-4D75-A5B5-B73B17931285
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename=signature.asc
Content-Type: application/pgp-signature;
	name=signature.asc
Content-Description: Message signed with OpenPGP using GPGMail

-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - https://gpgtools.org

iQIcBAEBCgAGBQJTfU5PAAoJED0hT49bxe1zGxoQAIhUJYsq0j3KYfc+ZV3QDdnC
CeL9Go87qPEQTXJzJU0Yk4y7PoCsxJ0oPnQOeaEOEzwiRJ2aRKJoLbfwu0lsTJo/
nT4abYSLx1EgqgtDkFSF62DXKnN2BWmyexw5FDJFQ1plzWJ1NYh4lncjM3wT5K0Z
Qb367T06+Ihp7iuU/LAi3zhwZumxntITqrWamBiqfu6Sn+u7EtKnMBxduczWNmFB
iPzJtaAcb+R2v/l2lKw3NqNS/ewtmZrduTQtwhuaFd16bfffC5dnFzcgr5W0nJt8
X0Kt+Vtr2mO445plqJhbq0MB2H1k6TuS+tBPCz9T/9dWEz4yRoa0GSaLgyN/rDOL
OyKMNanVMzKfy0egsXwiiAyL4rBbi7E3qDXG2x8bTBqDBlr9BxI54TdOVVexC7/2
puUvxfsZv3zrMojRVw8l+q9LZLGsjjPY7kv9OQqWSkYLhfON6wCpfdXzUuWO66Qq
mZFh6wkaWn9pJZLApzF8gQvmY+rRn4EXJs7cUCGes+mplMu3+v/H/6AksQWakxqA
PbJBaK4xsvwhOFKBWlqHxWxhQgIsTdkEmtkq9nDUsPjuohq/1ef8e7WtTo3ONVNF
5Bwe70x1EVGzsqz1e5xlJxKuuUTaTXJ9ep+hLCPydFVF+UJUUXjOgdkhusgoiWwI
uSgtPwHM/aqgQ36UdWkM
=gbJG
-----END PGP SIGNATURE-----

--Apple-Mail=_23EB31E1-FF71-4D75-A5B5-B73B17931285--