Skip to content

Commit 8419d2e

Browse files
committed
git-format-patch --in-reply-to: accept <message@id> with angle brackets
This will allow RFC-literate users to say: format-patch --in-reply-to='<message.id@site.name>' without forcing them to strip the surrounding angle brackets like this: format-patch --in-reply-to='message.id@site.name' We accept both forms, and the latter gets necessary < and > around it as before. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 767c98a commit 8419d2e

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

builtin-log.c

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,34 @@ static void gen_message_id(char *dest, unsigned int length, char *base)
437437
(int)(email_end - email_start - 1), email_start + 1);
438438
}
439439

440+
static const char *clean_message_id(const char *msg_id)
441+
{
442+
char ch;
443+
const char *a, *z, *m;
444+
char *n;
445+
size_t len;
446+
447+
m = msg_id;
448+
while ((ch = *m) && (isspace(ch) || (ch == '<')))
449+
m++;
450+
a = m;
451+
z = NULL;
452+
while ((ch = *m)) {
453+
if (!isspace(ch) && (ch != '>'))
454+
z = m;
455+
m++;
456+
}
457+
if (!z)
458+
die("insane in-reply-to: %s", msg_id);
459+
if (++z == m)
460+
return a;
461+
len = z - a;
462+
n = xmalloc(len + 1);
463+
memcpy(n, a, len);
464+
n[len] = 0;
465+
return n;
466+
}
467+
440468
int cmd_format_patch(int argc, const char **argv, const char *prefix)
441469
{
442470
struct commit *commit;
@@ -625,7 +653,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
625653
if (numbered)
626654
rev.total = total + start_number - 1;
627655
rev.add_signoff = add_signoff;
628-
rev.ref_message_id = in_reply_to;
656+
if (in_reply_to)
657+
rev.ref_message_id = clean_message_id(in_reply_to);
629658
while (0 <= --nr) {
630659
int shown;
631660
commit = list[nr];

0 commit comments

Comments
 (0)