[PATCH] git-format-patch --in-reply-to: accept <message@id> with angle brackets

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

 



This will allow RFC-literate users to say:

	format-patch --in-reply-to='<message.id@xxxxxxxxx>'

without forcing them to strip the surrounding angle brackets
like this:

	format-patch --in-reply-to='message.id@xxxxxxxxx'

We accept both forms, and the latter gets necessary < and >
around it as before.

Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
---

 Junio C Hamano <gitster@xxxxxxxxx> writes:

 > The patch and my comment on "git-format-patch --in-reply-to" are
 > merely about being user friendly.  We _could_ require the id
 > given by the user to have angle brackets.  But we do not have
 > to, because we can add them ourselves when the given string is
 > not enclosed by them.

 So here is a follow-up on David's patch.  

 builtin-log.c |   31 ++++++++++++++++++++++++++++++-
 1 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/builtin-log.c b/builtin-log.c
index fa81c25..c6cc3ae 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -437,6 +437,34 @@ static void gen_message_id(char *dest, unsigned int length, char *base)
 		 (int)(email_end - email_start - 1), email_start + 1);
 }
 
+static const char *clean_message_id(const char *msg_id)
+{
+	char ch;
+	const char *a, *z, *m;
+	char *n;
+	size_t len;
+
+	m = msg_id;
+	while ((ch = *m) && (isspace(ch) || (ch == '<')))
+		m++;
+	a = m;
+	z = NULL;
+	while ((ch = *m)) {
+		if (!isspace(ch) && (ch != '>'))
+			z = m;
+		m++;
+	}
+	if (!z)
+		die("insane in-reply-to: %s", msg_id);
+	if (++z == m)
+		return a;
+	len = z - a;
+	n = xmalloc(len + 1);
+	memcpy(n, a, len);
+	n[len] = 0;
+	return n;
+}
+
 int cmd_format_patch(int argc, const char **argv, const char *prefix)
 {
 	struct commit *commit;
@@ -625,7 +653,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 	if (numbered)
 		rev.total = total + start_number - 1;
 	rev.add_signoff = add_signoff;
-	rev.ref_message_id = in_reply_to;
+	if (in_reply_to)
+		rev.ref_message_id = clean_message_id(in_reply_to);
 	while (0 <= --nr) {
 		int shown;
 		commit = list[nr];



-
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]

  Powered by Linux