{"thread":{"id":"9895","subject":"git-send-email creates duplicate Message-Id's","startedAt":"2007-09-17T15:59:01Z","lastAt":"2007-09-17T20:47:01Z","messageCount":3,"participants":["Adrian Bunk","Junio C Hamano","Matti Aarnio"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"53323","messageId":"20070917155901.GP18232@stusta.de","threadId":"9895","inReplyTo":"11900179463203-git-send-email-avi@qumranet.com","subject":"git-send-email creates duplicate Message-Id's","fromName":"Adrian Bunk","fromEmail":"bunk@kernel.org","sentAt":"2007-09-17T15:59:01Z","receivedAt":"2007-09-17T15:59:01Z","isPatch":false,"sender":{"key":"bunk@kernel.org","avatar":null},"body":"The following might be a bug in git-send-email (git maintainers Cc'ed\nand KVM list removed from Cc): \n\nPatch 54 got the same Message-Id as patch 61 and patch 89 got the same \nMessage-Id as patch 104.\n\nThat's not legal, and users who automatically filter duplicate emails \nbased on the Message-Id will not see two of the patches.\n\nThe emails are:\nhttp://marc.info/?l=linux-kernel&m=119002061330270&w=2\nhttp://marc.info/?l=linux-kernel&m=119002059626434&w=2\nhttp://marc.info/?l=linux-kernel&m=119002060011801&w=2\nhttp://marc.info/?l=linux-kernel&m=119002060318915&w=2\n\ncu\nAdrian\n\n-- \n\n       \"Is there not promise of rain?\" Ling Tan asked suddenly out\n        of the darkness. There had been need of rain for many days.\n       \"Only a promise,\" Lao Er said.\n                                       Pearl S. Buck - Dragon Seed\n"},{"id":"53349","messageId":"7vejgxyrde.fsf@gitster.siamese.dyndns.org","threadId":"9895","inReplyTo":"20070917155901.GP18232@stusta.de","subject":"Re: git-send-email creates duplicate Message-Id's","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-09-17T20:22:05Z","receivedAt":"2007-09-17T20:22:05Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Adrian Bunk <bunk@kernel.org> writes:\n\n> The following might be a bug in git-send-email (git maintainers Cc'ed\n> and KVM list removed from Cc): \n>\n> Patch 54 got the same Message-Id as patch 61 and patch 89 got the same \n> Message-Id as patch 104.\n> ...\n> The emails are:\n> http://marc.info/?l=linux-kernel&m=119002061330270&w=2\n> http://marc.info/?l=linux-kernel&m=119002059626434&w=2\n> http://marc.info/?l=linux-kernel&m=119002060011801&w=2\n> http://marc.info/?l=linux-kernel&m=119002060318915&w=2\n\nThe old code generated rand(4200) for each message and appended\nit to the timestamp.  I do not know where the original author\ngot 4200 from, but I think if you send many messages within a\nsingle second it is possible to get collisions.\n\nI guess something like this patch is an improvement?  It\ngenerates a single prefix from timestamp and random, and appends\na number that is incremented for each message.\n\n---\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex dd7560b..e250732 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -477,10 +477,18 @@ sub extract_valid_address {\n \n # We'll setup a template for the message id, using the \"from\" address:\n \n+my ($message_id_stamp, $message_id_serial);\n sub make_message_id\n {\n-\tmy $date = time;\n-\tmy $pseudo_rand = int (rand(4200));\n+\tmy $uniq;\n+\tif (!defined $message_id_stamp) {\n+\t\t$message_id_stamp = sprintf(\"%s-%s\", time, int(rand(4200)));\n+\t\t$message_id_serial = 0;\n+\t}\n+\t$message_id_serial++;\n+\n+\t$uniq = \"$message_id_stamp-$message_id_serial\";\n+\n \tmy $du_part;\n \tfor ($sender, $repocommitter, $repoauthor) {\n \t\t$du_part = extract_valid_address(sanitize_address($_));\n@@ -490,8 +498,8 @@ sub make_message_id\n \t\tuse Sys::Hostname qw();\n \t\t$du_part = 'user@' . Sys::Hostname::hostname();\n \t}\n-\tmy $message_id_template = \"<%s-git-send-email-$du_part>\";\n-\t$message_id = sprintf $message_id_template, \"$date$pseudo_rand\";\n+\tmy $message_id_template = \"<%s-git-send-email-%s>\";\n+\t$message_id = sprintf($message_id_template, $uniq, $du_part);\n \t#print \"new message id = $message_id\\n\"; # Was useful for debugging\n }\n \n"},{"id":"53350","messageId":"20070917204701.GU6372@mea-ext.zmailer.org","threadId":"9895","inReplyTo":"7vejgxyrde.fsf@gitster.siamese.dyndns.org","subject":"Re: git-send-email creates duplicate Message-Id's","fromName":"Matti Aarnio","fromEmail":"matti.aarnio@zmailer.org","sentAt":"2007-09-17T20:47:01Z","receivedAt":"2007-09-17T20:47:01Z","isPatch":false,"sender":{"key":"matti.aarnio@zmailer.org","avatar":null},"body":"On Mon, Sep 17, 2007 at 01:22:05PM -0700, Junio C Hamano wrote:\n> Adrian Bunk <bunk@kernel.org> writes:\n> \n> > The following might be a bug in git-send-email (git maintainers Cc'ed\n> > and KVM list removed from Cc): \n> >\n> > Patch 54 got the same Message-Id as patch 61 and patch 89 got the same \n> > Message-Id as patch 104.\n> > ...\n> > The emails are:\n> > http://marc.info/?l=linux-kernel&m=119002061330270&w=2\n> > http://marc.info/?l=linux-kernel&m=119002059626434&w=2\n> > http://marc.info/?l=linux-kernel&m=119002060011801&w=2\n> > http://marc.info/?l=linux-kernel&m=119002060318915&w=2\n> \n> The old code generated rand(4200) for each message and appended\n> it to the timestamp.  I do not know where the original author\n> got 4200 from, but I think if you send many messages within a\n> single second it is possible to get collisions.\n> \n> I guess something like this patch is an improvement?  It\n> generates a single prefix from timestamp and random, and appends\n> a number that is incremented for each message.\n\nMuch better.   You may also consider a possibility of\nletting your local MTA do the  Message-ID generation, unless\nyou are tracking something with it and thus need to know the\ngenerated values.  .. but apparently git much prefers sending\nemail by SMTP, where the message-id must be present, or one\nreally should block any such emails..  (except that systems\nlike qmail send error messages without message-id ...)\n\nMy own recipe is:\n       sprintf(\"%d-%d-%d\", time , getpid, ++localsequence)\ncatenate on that your favourite domain name where that recipe\nis likely to be valid, and you are all set.\n\n\n  /Matti Aarnio  --  one of  <postmaster@vger.kernel.org>\n"}]}