@matheusbsbs / matheus-bagliano / commits / c4adea82c5
Fork 0

Convert CR/LF to LF in tag signatures

On Windows, gpg outputs CR/LF signatures. But since the tag messages are already stripped of the CR by stripspace(), it is arguably nicer to do the same for the tag signature. Actually, this patch does not look for CR/LF, but strips all CRs from the signature. It does so not only on Windows but on all platforms to keep the code simpler. [ spr: ported code to use strbuf ] Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Steffen Prohaska <prohaska@zib.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Jul 11, 2008 at 18:55 UTC c4adea82c5064971ff6d090be8db89c44456186b
1 file changed +10
builtin-tag.c
+10
@@ -202,6 +202,7 @@ static int do_sign(struct strbuf *buffer)
202 const char *args[4];
203 char *bracket;
204 int len;
205 + int i, j;
206
207 if (!*signingkey) {
208 if (strlcpy(signingkey, git_committer_info(IDENT_ERROR_ON_NO_NAME),
@@ -241,6 +242,15 @@ static int do_sign(struct strbuf *buffer)
242 if (finish_command(&gpg) || !len || len < 0)
243 return error("gpg failed to sign the tag");
244
245 + /* Strip CR from the line endings, in case we are on Windows. */
246 + for (i = j = 0; i < buffer->len; i++)
247 + if (buffer->buf[i] != '\r') {
248 + if (i != j)
249 + buffer->buf[j] = buffer->buf[i];
250 + j++;
251 + }
252 + strbuf_setlen(buffer, j);
253 +
254 return 0;
255 }
256