{"thread":{"id":"4597","subject":"Re: [PATCH 1/3] gitweb: whitespace cleanup","startedAt":"2006-06-21T08:05:10Z","lastAt":"2006-07-03T02:49:50Z","messageCount":7,"participants":["Jakub Narebski","Junio C Hamano","Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"22174","messageId":"8fe92b430606210105r29a1691bk1c605de715af091c@mail.gmail.com","threadId":"4597","inReplyTo":"11508760842024-git-send-email-jnareb@gmail.com","subject":"Re: [PATCH 1/3] gitweb: whitespace cleanup","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-06-21T08:05:10Z","receivedAt":"2006-06-21T08:05:10Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> wrote:\n>\n> Signed-off-by: Jakub Narebski <jnareb.com>\n\nIt should be of course\n\n Signed-off-by: Jakub Narebski <jnareb@gmail.com>\n\n\nSomehow cover letter got lost, and patches did not appear on mailing\nlist archives.\nIf the mail will not appear in few hours, I'll resend it to mailing list only.\n\nProbably because git-send-email should ensure LC_ALL=C for Date:\nheader generation...\n-- \nJakub Narebski\nShadeHawk on #git\n"},{"id":"22180","messageId":"7v3bdy5178.fsf@assigned-by-dhcp.cox.net","threadId":"4597","inReplyTo":"11508760843417-git-send-email-jnareb@gmail.com","subject":"Re: [PATCH 0/3] Minor gitweb modifications and cleanups","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-06-21T09:04:43Z","receivedAt":"2006-06-21T09:04:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> This series of patches is based on git.git 'next' branch\n> 69d830d1a3a1236036bd0f84dd9794d7c8d34b3f\n>\n> My future gitweb-related batches will be based on this series.\n>\n> ---\n>\n>  gitweb/gitweb.cgi |   53 +++++++++++++++++++++++++++++++----------------------\n>  gitweb/gitweb.css |    4 ++--\n>  2 files changed, 33 insertions(+), 24 deletions(-)\n>\n> -- \n> Jakub Narebski\n> Poland\n\nAll three applied cleanly (finally!), but with hand munging of\nDate: field.\n\nI think git-send-email should internally do LC_ALL=C or stop\nusing strftime() or both.\n"},{"id":"22181","messageId":"11508811631669-git-send-email-jnareb@gmail.com","threadId":"4597","inReplyTo":"7v3bdy5178.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] send-email: Use setlocale in addition to $ENV{LC_ALL} to set locale","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-06-21T09:12:43Z","receivedAt":"2006-06-21T09:12:43Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"$ENV{LC_ALL} = 'C'; does not change locale used by strftime.\nUse setlocale( LC_ALL, 'C' ); instead.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n\n---\n\n git-send-email.perl |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\n7c796152570e28d3f95c17e93864c6abc8edef24\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 7b1cca7..56949dd 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -24,7 +24,8 @@ use Data::Dumper;\n \n # most mail servers generate the Date: header, but not all...\n $ENV{LC_ALL} = 'C';\n-use POSIX qw/strftime/;\n+use POSIX qw/strftime setlocale LC_ALL/;\n+setlocale( &LC_ALL, 'C' );\n \n my $have_email_valid = eval { require Email::Valid; 1 };\n my $smtp;\n-- \n1.3.0\n"},{"id":"22192","messageId":"e7b796$lj$1@sea.gmane.org","threadId":"4597","inReplyTo":"11508811631669-git-send-email-jnareb@gmail.com","subject":"Re: [PATCH] send-email: Use setlocale in addition to $ENV{LC_ALL} to set locale","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-06-21T10:33:18Z","receivedAt":"2006-06-21T10:33:18Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Jakub Narebski wrote:\n\n> $ENV{LC_ALL} = 'C'; does not change locale used by strftime.\n> Use setlocale( LC_ALL, 'C' ); instead.\n\n>  # most mail servers generate the Date: header, but not all...\n>  $ENV{LC_ALL} = 'C';\n> -use POSIX qw/strftime/;\n> +use POSIX qw/strftime setlocale LC_ALL/;\n> +setlocale( &LC_ALL, 'C' );\n\nPerhaps instead of \n  setlocale( &LC_ALL, 'C' );\nwe should use\n  setlocale( &LC_ALL, '' );\n(i.e. set the LC_ALL behaviour according to the locale environment\nvariables). I'm not that versed in locale, POSIX and Perl.\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"22193","messageId":"20060621104941.GB15748@localdomain","threadId":"4597","inReplyTo":"e7b796$lj$1@sea.gmane.org","subject":"Re: [PATCH] send-email: Use setlocale in addition to $ENV{LC_ALL} to set locale","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-06-21T10:49:41Z","receivedAt":"2006-06-21T10:49:41Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Jakub Narebski <jnareb@gmail.com> wrote:\n> Jakub Narebski wrote:\n> \n> > $ENV{LC_ALL} = 'C'; does not change locale used by strftime.\n> > Use setlocale( LC_ALL, 'C' ); instead.\n> \n> >  # most mail servers generate the Date: header, but not all...\n> >  $ENV{LC_ALL} = 'C';\n> > -use POSIX qw/strftime/;\n> > +use POSIX qw/strftime setlocale LC_ALL/;\n> > +setlocale( &LC_ALL, 'C' );\n> \n> Perhaps instead of \n>   setlocale( &LC_ALL, 'C' );\n> we should use\n>   setlocale( &LC_ALL, '' );\n> (i.e. set the LC_ALL behaviour according to the locale environment\n> variables). I'm not that versed in locale, POSIX and Perl.\n\nI'm responsible for the $ENV{LC_ALL} = 'C' setting but I never actually\ntested how things would work with a non-English locale (not being\nwell-versed in these things myself, either).\n\nI've always wondered about why /usr/bin/822-date existed without\nstrftime on my Debian systems but never bothered asking, I guess this\ncould be a good reason why...\n\nFor reference, here's the /usr/bin/822-date script\n(trailing whitespace fixed):\n\n------- 8< -------\n\n#!/usr/bin/perl --\n# I hereby place this in the public domain - Ian Jackson, 1995.\n# Changes by Klee Dienes also placed in public domain (1997).\n\n# time structure:\n# [ sec min hour mday mon year wday yday isdst ]\n\n@ARGV && die \"usage: 822-date\\n\";\n\n$curtime = time;\n@localtm = localtime ($curtime);\n$localtms = localtime ($curtime);\n@gmttm = gmtime ($curtime);\n$gmttms = gmtime ($curtime);\n\nif ($localtm[0] != $gmttm[0]) {\n    die (sprintf (\"local timezone differs from GMT by a non-minute interval\\n\"\n\t\t . \"local time: %s\\n\"\n\t\t . \"GMT time: %s\\n\", $localtms, $gmttms));\n}\n\n$localmin = $localtm[1] + $localtm[2] * 60;\n$gmtmin = $gmttm[1] + $gmttm[2] * 60;\n\nif ((($gmttm[6] + 1) % 7) == $localtm[6]) {\n    $localmin += 1440;\n} elsif ((($gmttm[6] - 1) % 7) == $localtm[6]) {\n    $localmin -= 1440;\n} elsif ($gmttm[6] == $localtm[6]) {\n    1;\n} else {\n    die (\"822-date: local time offset greater than or equal to 24 hours\\n\");\n}\n\n$offset = $localmin - $gmtmin;\n$offhour = $offset / 60;\n$offmin = abs ($offset % 60);\n\nif (abs ($offhour) >= 24) {\n    die (\"822-date: local time offset greater than or equal to 24 hours\\n\");\n}\n\nprintf\n    (\n     \"%s, %2d %s %d %02d:%02d:%02d %s%02d%02d\\n\",\n     (Sun,Mon,Tue,Wed,Thu,Fri,Sat)[$localtm[6]], # day of week\n     $localtm[3],\t\t# day of month\n     (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)[$localtm[4]], # month\n     $localtm[5]+1900,\t\t# year\n     $localtm[2],\t\t# hour\n     $localtm[1],\t\t# minute\n     $localtm[0],\t\t# sec\n     ($offset >= 0) ? '+' : '-',# TZ offset direction\n     abs ($offhour),\t\t# TZ offset hour\n     $offmin,\t\t\t# TZ offset minute\n     ) || die \"822-date: output error: $!\\n\";\n\n------- 8< -------\n\n-- \nEric Wong\n"},{"id":"22200","messageId":"e7b9u7$974$1@sea.gmane.org","threadId":"4597","inReplyTo":"20060621104941.GB15748@localdomain","subject":"Re: [PATCH] send-email: Use setlocale in addition to $ENV{LC_ALL} to set locale","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-06-21T11:18:40Z","receivedAt":"2006-06-21T11:18:40Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Eric Wong wrote:\n\n> Jakub Narebski <jnareb@gmail.com> wrote:\n>> \n>>> $ENV{LC_ALL} = 'C'; does not change locale used by strftime.\n>>> Use setlocale( &LC_ALL, 'C' ); instead.\n\n> I'm responsible for the $ENV{LC_ALL} = 'C' setting but I never actually\n> tested how things would work with a non-English locale (not being\n> well-versed in these things myself, either).\n\nIt looks like I have broken locale badly somewhat, as I yesterday\nsent patches successfully without the patch. I suspect that sendmail\nremoves incorrect Date: header and adds it's own... unless Date:\nheader contains characters outside US-ASCII.\n\nIt means that sendmail can deal with\n  Date: wto, 20 cze 2006 13:14:11 +0200\ninstead of correct\n  Date: Tue, 20 Jun 2006 13:14:11 +0200\n\nbut cannot deal with (iso-8859-2 encoded I think)\n  Date: ¶ro, 21 cze 2006 09:48:02 +0200\nfrom git-send-email.perl without patch, instead of correct\n  Date: Wed, 21 Jun 2006 11:25:52 +0200\nwith the patch.\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"23081","messageId":"7vd5cnv1v5.fsf@assigned-by-dhcp.cox.net","threadId":"4597","inReplyTo":"20060621104941.GB15748@localdomain","subject":"Re: [PATCH] send-email: Use setlocale in addition to $ENV{LC_ALL} to set locale","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-07-03T02:49:50Z","receivedAt":"2006-07-03T02:49:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"I was reviewing old log and noticed this topic has never been\nresolved.  Your proposal was to use POSIX::setlocale(), and\nEric's counter-proposal was to mimic what 822-date script does,\ndoing it by hand without mucking with locales, and the\ndiscussion seemed to have died there.  Does this still need to\nbe addressed?\n\nMy gut feeling is that it would probably be less problematic if\nwe do not muck with locales at all (so drop POSIX::strftime as\nwell).\n\nSo maybe something like this (totally untested)?\n\n-- >8 --\n[PATCH] do not use locale specific strftime when preparing 2822 date\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex c5d9e73..bc42761 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -23,8 +23,43 @@ use Getopt::Long;\n use Data::Dumper;\n \n # most mail servers generate the Date: header, but not all...\n-$ENV{LC_ALL} = 'C';\n-use POSIX qw/strftime/;\n+sub format_2822_time {\n+\tmy ($time) = @_;\n+\tmy @localtm = localtime($time);\n+\tmy @gmttm = gmtime($time);\n+\tmy $localmin = $localtm[1] + $localtm[2] * 60;\n+\tmy $gmtmin = $gmttm[1] + $gmttm[2] * 60;\n+\tif ($localtm[0] != $gmttm[0]) {\n+\t\tdie \"local zone differs from GMT by a non-minute interval\\n\";\n+\t}\n+\tif ((($gmttm[6] + 1) % 7) == $localtm[6]) {\n+\t\t$localmin += 1440;\n+\t} elsif ((($gmttm[6] - 1) % 7) == $localtm[6]) {\n+\t\t$localmin -= 1440;\n+\t} elsif ($gmttm[6] != $localtm[6]) {\n+\t\tdie \"local time offset greater than or equal to 24 hours\\n\";\n+\t}\n+\tmy $offset = $localmin - $gmtmin;\n+\tmy $offhour = $offset / 60;\n+\tmy $offmin = abs($offset % 60);\n+\tif (abs($offhour) >= 24) {\n+\t\tdie (\"local time offset greater than or equal to 24 hours\\n\");\n+\t}\n+\n+\treturn sprintf(\"%s, %2d %s %d %02d:%02d:%02d %s%02d%02d\",\n+\t\t       qw(Sun Mon Tue Wed Thu Fri Sat)[$localtm[6]],\n+\t\t       $localtm[3],\n+\t\t       qw(Jan Feb Mar Apr May Jun\n+\t\t\t  Jul Aug Sep Oct Nov Dec)[$localtm[4]],\n+\t\t       $localtm[5]+1900,\n+\t\t       $localtm[2],\n+\t\t       $localtm[1],\n+\t\t       $localtm[0],\n+\t\t       ($offset >= 0) ? '+' : '-',\n+\t\t       abs($offhour),\n+\t\t       $offmin,\n+\t\t       );\n+}\n \n my $have_email_valid = eval { require Email::Valid; 1 };\n my $smtp;\n@@ -371,7 +405,7 @@ sub send_message\n \tmy @recipients = unique_email_list(@to);\n \tmy $to = join (\",\\n\\t\", @recipients);\n \t@recipients = unique_email_list(@recipients,@cc,@bcclist);\n-\tmy $date = strftime('%a, %d %b %Y %H:%M:%S %z', localtime($time++));\n+\tmy $date = format_2822_time($time++);\n \tmy $gitversion = '@@GIT_VERSION@@';\n \tif ($gitversion =~ m/..GIT_VERSION../) {\n \t    $gitversion = `git --version`;\n"}]}