Skip to content

Commit

Permalink
Convert CR/LF to LF in tag signatures
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Jul 12, 2008
1 parent f9dd4bf commit c4adea8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions builtin-tag.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ static int do_sign(struct strbuf *buffer)
const char *args[4];
char *bracket;
int len;
int i, j;

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

/* Strip CR from the line endings, in case we are on Windows. */
for (i = j = 0; i < buffer->len; i++)
if (buffer->buf[i] != '\r') {
if (i != j)
buffer->buf[j] = buffer->buf[i];
j++;
}
strbuf_setlen(buffer, j);

return 0;
}

Expand Down

0 comments on commit c4adea8

Please sign in to comment.