Skip to content

Commit c4adea8

Browse files
dschogitster
authored andcommitted
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>
1 parent f9dd4bf commit c4adea8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

builtin-tag.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ static int do_sign(struct strbuf *buffer)
202202
const char *args[4];
203203
char *bracket;
204204
int len;
205+
int i, j;
205206

206207
if (!*signingkey) {
207208
if (strlcpy(signingkey, git_committer_info(IDENT_ERROR_ON_NO_NAME),
@@ -241,6 +242,15 @@ static int do_sign(struct strbuf *buffer)
241242
if (finish_command(&gpg) || !len || len < 0)
242243
return error("gpg failed to sign the tag");
243244

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+
244254
return 0;
245255
}
246256

0 commit comments

Comments
 (0)