Skip to content

Commit f916ab0

Browse files
Eric Wonggitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7654286 commit f916ab0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

git-send-email.perl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use 5.008;
2020
use strict;
2121
use warnings;
22+
use POSIX qw/strftime/;
2223
use Term::ReadLine;
2324
use Getopt::Long;
2425
use Text::ParseWords;
@@ -910,7 +911,7 @@ sub validate_address_list {
910911
sub make_message_id {
911912
my $uniq;
912913
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));
914915
$message_id_serial = 0;
915916
}
916917
$message_id_serial++;
@@ -925,7 +926,7 @@ sub make_message_id {
925926
require Sys::Hostname;
926927
$du_part = 'user@' . Sys::Hostname::hostname();
927928
}
928-
my $message_id_template = "<%s-git-send-email-%s>";
929+
my $message_id_template = "<%s-%s>";
929930
$message_id = sprintf($message_id_template, $uniq, $du_part);
930931
#print "new message id = $message_id\n"; # Was useful for debugging
931932
}

0 commit comments

Comments
 (0)