git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Make git tag -s friendly to keys with comments

From
Petr Baudis <pasky@suse.cz>
Date
Jun 9, 2009, 23:48 UTC
Message-ID
<20090609234851.GA5286@machine.or.cz>

git tag -s has very unfriendly default method of picking key ids; it is documented in git-tag(1) as just the e-mail, but in fact it is "Real Name <email>". This will never pick the right default if the key was created with a comment in the name, like:

	Petr Baudis (Sirius Labs) <pasky@ucw.cz>
	Petr Baudis (SuSE Labs) <pasky@suse.cz>

This patch makes git tag -s default to just the e-mail address, as documented.

Signed-off-by: Petr Baudis <pasky@suse.cz>
---
diff --git a/builtin-tag.c b/builtin-tag.c
index e544430..9901925 100644
--- a/builtin-tag.c
+++ b/builtin-tag.c
@@ -165,8 +165,10 @@ static int do_sign(struct strbuf *buffer)
 	int i, j;
 
 	if (!*signingkey) {
-		if (strlcpy(signingkey, git_committer_info(IDENT_ERROR_ON_NO_NAME),
-				sizeof(signingkey)) > sizeof(signingkey) - 1)
+		char *commit_email = strchr(git_committer_info(IDENT_ERROR_ON_NO_NAME), '<');
+		assert(commit_email);
+		if (strlcpy(signingkey, commit_email, sizeof(signingkey))
+				> sizeof(signingkey) - 1)
 			return error("committer info too long.");
 		bracket = strchr(signingkey, '>');
 		if (bracket)
-- 
				Petr "Pasky" Baudis
The lyf so short, the craft so long to lerne. -- Chaucer
Message 1 of 1 in “Make git tag -s friendly to keys with comments”
  1. Make git tag -s friendly to keys with commentsPetr Baudis, Jun 9, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.