Skip to content

Commit abfbff6

Browse files
committed
tag: fix sign_buffer() call to create a signed tag
The command "git tag -s" internally calls sign_buffer() to make a cryptographic signature using the chosen backend like GPG and SSH. The internal helper functions used by "git tag" implementation seem to use a "negative return values are errors, zero or positive return values are not" convention, and there are places (e.g., verify_tag() that calls gpg_verify_tag()) that these internal helper functions translate return values that signal errors to conform to this convention, but do_sign() that calls sign_buffer() forgets to do so. Fix it, so that a failed call to sign_buffer() that can return the exit status from pipe_command() will not be overlooked. Reported-by: Sergey Kosukhin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 564d025 commit abfbff6

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

builtin/tag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static int verify_tag(const char *name, const char *ref UNUSED,
176176

177177
static int do_sign(struct strbuf *buffer)
178178
{
179-
return sign_buffer(buffer, buffer, get_signing_key());
179+
return sign_buffer(buffer, buffer, get_signing_key()) ? -1 : 0;
180180
}
181181

182182
static const char tag_template[] =

gpg-interface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ size_t parse_signed_buffer(const char *buf, size_t size);
6666
* Create a detached signature for the contents of "buffer" and append
6767
* it after "signature"; "buffer" and "signature" can be the same
6868
* strbuf instance, which would cause the detached signature appended
69-
* at the end.
69+
* at the end. Returns 0 on success, non-zero on failure.
7070
*/
7171
int sign_buffer(struct strbuf *buffer, struct strbuf *signature,
7272
const char *signing_key);

0 commit comments

Comments
 (0)