send-email: more meaningful Message-ID

Using a YYYYmmddHHMMSS date representation is more meaningful to humans, especially when used for lookups on NNTP servers or linking to archive sites via Message-ID (e.g. mid.gmane.org or mid.mail-archive.com). This timestamp format more easily gives a reader of the URL itself a rough date of a linked message compared to having them calculate the seconds since the Unix epoch. Furthermore, having the MUA name in the Message-ID seems to be a rare oddity I haven't noticed outside of git-send-email. We already have an optional X-Mailer header field to advertise for us, so extending the Message-ID by 15 characters can make for unpleasant Message-ID-based URLs to archive sites. Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Eric Wong committed Apr 6, 2016 at 20:07 UTC f916ab0ccc1fbeee5a63ec29246ba99df7ff256f
1 file changed +3 -2
git-send-email.perl
+3 -2
@@ -19,6 +19,7 @@
19 use 5.008;
20 use strict;
21 use warnings;
22 +use POSIX qw/strftime/;
23 use Term::ReadLine;
24 use Getopt::Long;
25 use Text::ParseWords;
@@ -910,7 +911,7 @@ my ($message_id_stamp, $message_id_serial);
911 sub make_message_id {
912 my $uniq;
913 if (!defined $message_id_stamp) {
913 - $message_id_stamp = sprintf("%s-%s", time, $$);
914 + $message_id_stamp = strftime("%Y%m%d%H%M%S.$$", gmtime(time));
915 $message_id_serial = 0;
916 }
917 $message_id_serial++;
@@ -925,7 +926,7 @@ sub make_message_id {
926 require Sys::Hostname;
927 $du_part = 'user@' . Sys::Hostname::hostname();
928 }
928 - my $message_id_template = "<%s-git-send-email-%s>";
929 + my $message_id_template = "<%s-%s>";
930 $message_id = sprintf($message_id_template, $uniq, $du_part);
931 #print "new message id = $message_id\n"; # Was useful for debugging
932 }