git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] send-email: more meaningful Message-ID
@ 2016-04-05 19:39 Eric Wong
  2016-04-05 21:10 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Wong @ 2016-04-05 19:39 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Eric Wong

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>
---
 git-send-email.perl | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index d356901..23141e7 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -949,7 +949,8 @@ my ($message_id_stamp, $message_id_serial);
 sub make_message_id {
 	my $uniq;
 	if (!defined $message_id_stamp) {
-		$message_id_stamp = sprintf("%s-%s", time, $$);
+		use POSIX qw/strftime/;
+		$message_id_stamp = strftime("%Y%m%d%H%M%S.$$", gmtime(time));
 		$message_id_serial = 0;
 	}
 	$message_id_serial++;
@@ -964,7 +965,7 @@ sub make_message_id {
 		require Sys::Hostname;
 		$du_part = 'user@' . Sys::Hostname::hostname();
 	}
-	my $message_id_template = "<%s-git-send-email-%s>";
+	my $message_id_template = "<%s-%s>";
 	$message_id = sprintf($message_id_template, $uniq, $du_part);
 	#print "new message id = $message_id\n"; # Was useful for debugging
 }
-- 
EW

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] send-email: more meaningful Message-ID
  2016-04-05 19:39 [PATCH] send-email: more meaningful Message-ID Eric Wong
@ 2016-04-05 21:10 ` Junio C Hamano
  2016-04-05 21:36   ` Eric Wong
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2016-04-05 21:10 UTC (permalink / raw)
  To: Eric Wong; +Cc: git

Eric Wong <normalperson@yhbt.net> writes:

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

Sounds like a sensible goal.  Just a few comments.

 - Is it safe to assume that we always can use POSIX::strftime(), or
   do we need some fallback?  I am guessing that this is safe, as
   POSIX has been part of the core modules for a long time, and the
   script does "use 5.008" upfront.

 - It is my understanding that, as "use" is a compilation-time
   thing, hiding it inside a block does not help reducing the
   start-up overhead (people can use "require" if they want to do a
   lazy loading and optionally a fallback).  Is my Perl5 outdated?
   Otherwise, let's have it near the beginning of the script, close
   to where we use Term::ReadLine and others.

Thanks.

>  git-send-email.perl | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/git-send-email.perl b/git-send-email.perl
> index d356901..23141e7 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -949,7 +949,8 @@ my ($message_id_stamp, $message_id_serial);
>  sub make_message_id {
>  	my $uniq;
>  	if (!defined $message_id_stamp) {
> -		$message_id_stamp = sprintf("%s-%s", time, $$);
> +		use POSIX qw/strftime/;
> +		$message_id_stamp = strftime("%Y%m%d%H%M%S.$$", gmtime(time));
>  		$message_id_serial = 0;
>  	}
>  	$message_id_serial++;
> @@ -964,7 +965,7 @@ sub make_message_id {
>  		require Sys::Hostname;
>  		$du_part = 'user@' . Sys::Hostname::hostname();
>  	}
> -	my $message_id_template = "<%s-git-send-email-%s>";
> +	my $message_id_template = "<%s-%s>";
>  	$message_id = sprintf($message_id_template, $uniq, $du_part);
>  	#print "new message id = $message_id\n"; # Was useful for debugging
>  }

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] send-email: more meaningful Message-ID
  2016-04-05 21:10 ` Junio C Hamano
@ 2016-04-05 21:36   ` Eric Wong
  2016-04-06 13:08     ` Johannes Schindelin
  2016-04-06 20:07     ` [PATCH v2] " Eric Wong
  0 siblings, 2 replies; 5+ messages in thread
From: Eric Wong @ 2016-04-05 21:36 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Johannes Schindelin, Johannes Sixt

Junio C Hamano <gitster@pobox.com> wrote:
> Eric Wong <normalperson@yhbt.net> writes:
> 
> > 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>
> > ---
> 
> Sounds like a sensible goal.  Just a few comments.
> 
>  - Is it safe to assume that we always can use POSIX::strftime(), or
>    do we need some fallback?  I am guessing that this is safe, as
>    POSIX has been part of the core modules for a long time, and the
>    script does "use 5.008" upfront.

I'm hoping so :)  And none of the format specifiers used here
should be subject to locale-dependent weirdness, at least.

+Cc both Johannes for Windows knowledge.

>  - It is my understanding that, as "use" is a compilation-time
>    thing, hiding it inside a block does not help reducing the
>    start-up overhead (people can use "require" if they want to do a
>    lazy loading and optionally a fallback).  Is my Perl5 outdated?
>    Otherwise, let's have it near the beginning of the script, close
>    to where we use Term::ReadLine and others.

You're correct, I'll move the "use" to the top in v2.

I could call "require" and call the sub as "POSIX::strftime",
but this code path is likely enough that any startup time
improvement for uncommon cases wouldn't be worth it.

Will wait a bit for strftime portability comments before v2.

> > --- a/git-send-email.perl
> > +++ b/git-send-email.perl
> > @@ -949,7 +949,8 @@ my ($message_id_stamp, $message_id_serial);
> >  sub make_message_id {
> >  	my $uniq;
> >  	if (!defined $message_id_stamp) {
> > -		$message_id_stamp = sprintf("%s-%s", time, $$);
> > +		use POSIX qw/strftime/;
> > +		$message_id_stamp = strftime("%Y%m%d%H%M%S.$$", gmtime(time));
> >  		$message_id_serial = 0;
> >  	}
> >  	$message_id_serial++;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] send-email: more meaningful Message-ID
  2016-04-05 21:36   ` Eric Wong
@ 2016-04-06 13:08     ` Johannes Schindelin
  2016-04-06 20:07     ` [PATCH v2] " Eric Wong
  1 sibling, 0 replies; 5+ messages in thread
From: Johannes Schindelin @ 2016-04-06 13:08 UTC (permalink / raw)
  To: Eric Wong; +Cc: Junio C Hamano, git, Johannes Sixt

Hi,

On Tue, 5 Apr 2016, Eric Wong wrote:

> Junio C Hamano <gitster@pobox.com> wrote:
> > Eric Wong <normalperson@yhbt.net> writes:
> > 
> > > 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>
> > > ---
> > 
> > Sounds like a sensible goal.  Just a few comments.
> > 
> >  - Is it safe to assume that we always can use POSIX::strftime(), or
> >    do we need some fallback?  I am guessing that this is safe, as
> >    POSIX has been part of the core modules for a long time, and the
> >    script does "use 5.008" upfront.
> 
> I'm hoping so :)  And none of the format specifiers used here
> should be subject to locale-dependent weirdness, at least.
> 
> +Cc both Johannes for Windows knowledge.

Thanks.

send-email is implemented as a Perl script, and Git for Windows uses a
Perl interpreter for such scripts which uses MSYS2's POSIX emulation
layer, i.e. POSIX calls are fine.

Short answer: no problem there, not even on Windows.

Of course, Git for Windows users are much more likely to use a Pull
Request based workflow than a mail-based one, so it is even less of a
problem for us.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] send-email: more meaningful Message-ID
  2016-04-05 21:36   ` Eric Wong
  2016-04-06 13:08     ` Johannes Schindelin
@ 2016-04-06 20:07     ` Eric Wong
  1 sibling, 0 replies; 5+ messages in thread
From: Eric Wong @ 2016-04-06 20:07 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Johannes Schindelin, Johannes Sixt

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>
---
  v2 - moved "use" to the top
  Thanks to Dscho for addressing Windows comments:
  http://mid.gmane.org/alpine.DEB.2.20.1604061505010.3371@virtualbox

 git-send-email.perl | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index d356901..52cf828 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -19,6 +19,7 @@
 use 5.008;
 use strict;
 use warnings;
+use POSIX qw/strftime/;
 use Term::ReadLine;
 use Getopt::Long;
 use Text::ParseWords;
@@ -949,7 +950,7 @@ my ($message_id_stamp, $message_id_serial);
 sub make_message_id {
 	my $uniq;
 	if (!defined $message_id_stamp) {
-		$message_id_stamp = sprintf("%s-%s", time, $$);
+		$message_id_stamp = strftime("%Y%m%d%H%M%S.$$", gmtime(time));
 		$message_id_serial = 0;
 	}
 	$message_id_serial++;
@@ -964,7 +965,7 @@ sub make_message_id {
 		require Sys::Hostname;
 		$du_part = 'user@' . Sys::Hostname::hostname();
 	}
-	my $message_id_template = "<%s-git-send-email-%s>";
+	my $message_id_template = "<%s-%s>";
 	$message_id = sprintf($message_id_template, $uniq, $du_part);
 	#print "new message id = $message_id\n"; # Was useful for debugging
 }
-- 
EW

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-04-06 20:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-05 19:39 [PATCH] send-email: more meaningful Message-ID Eric Wong
2016-04-05 21:10 ` Junio C Hamano
2016-04-05 21:36   ` Eric Wong
2016-04-06 13:08     ` Johannes Schindelin
2016-04-06 20:07     ` [PATCH v2] " Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).