@matheusbsbs / matheus-bagliano / commits / 8419d2ee9b
Fork 0

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>

Junio C Hamano committed Sep 13, 2007 at 22:30 UTC 8419d2ee9ba8b375186a5c1019df8dfbce610aba
1 file changed +30 -1
builtin-log.c
+30 -1
@@ -437,6 +437,34 @@ static void gen_message_id(char *dest, unsigned int length, char *base)
437 (int)(email_end - email_start - 1), email_start + 1);
438 }
439
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 +
468 int cmd_format_patch(int argc, const char **argv, const char *prefix)
469 {
470 struct commit *commit;
@@ -625,7 +653,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
653 if (numbered)
654 rev.total = total + start_number - 1;
655 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);
658 while (0 <= --nr) {
659 int shown;
660 commit = list[nr];