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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
	Petr Baudis (SuSE Labs) <pasky@xxxxxxx>

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

Signed-off-by: Petr Baudis <pasky@xxxxxxx>

---

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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]