{"thread":{"id":"29455","subject":"gitweb showing slash r at the end of line","startedAt":"2012-01-27T14:19:14Z","lastAt":"2012-02-02T20:04:06Z","messageCount":8,"participants":["Ondra Medek","Jakub Narebski","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"183190","messageId":"1327673954458-7229895.post@n2.nabble.com","threadId":"29455","inReplyTo":null,"subject":"gitweb showing slash r at the end of line","fromName":"Ondra Medek","fromEmail":"xmedeko@gmail.com","sentAt":"2012-01-27T14:19:14Z","receivedAt":"2012-01-27T14:19:14Z","isPatch":false,"sender":{"key":"xmedeko@gmail.com","avatar":"https://gravatar.com/avatar/09ec305680e81ade2e3617fd245cda7136f6d5e859b5120feb9436e0725f6e1d?d=mp&s=160"},"body":"Hi,\nwe have gitweb running on Linux box. Some files have Windows line ending\n(CRLF) end we do not use core.autcrlf translation. gitweb show the last \\r\nin the end of each line, which is annoying. I have creates a simple patch to\navoid this. It adds just one line. I am not sure if the regexp should\ncontain 'g' switch in the end. Also, not sure if there shoul be some config\noption to switch on/off this?\n\nCheers\nOndra\n---\n gitweb/gitweb.perl |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex abb5a79..92175bc 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -1500,6 +1500,7 @@ sub esc_html {\n        if ($opts{'-nbsp'}) {\n                $str =~ s/ /&nbsp;/g;\n        }\n+       $str =~ s/\\r$//;\n        $str =~ s|([[:cntrl:]])|(($1 ne \"\\t\") ? quot_cec($1) : $1)|eg;\n        return $str;\n }\n--\n1.7.8.4\n\n\n--\nView this message in context: http://git.661346.n2.nabble.com/gitweb-showing-slash-r-at-the-end-of-line-tp7229895p7229895.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"183202","messageId":"m3aa58eskw.fsf@localhost.localdomain","threadId":"29455","inReplyTo":"1327673954458-7229895.post@n2.nabble.com","subject":"Re: gitweb showing slash r at the end of line","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2012-01-27T21:35:45Z","receivedAt":"2012-01-27T21:35:45Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Ondra Medek <xmedeko@gmail.com> writes:\n\n> we have gitweb running on Linux box. Some files have Windows line ending\n> (CRLF) end we do not use core.autcrlf translation. gitweb show the last \\r\n> in the end of each line, which is annoying.\n\nWell, this \"\\r\" allows to recognize when file with Windows line ending\n(CRLF) made it into repository... which usually is discouraged.  But\nif you allow this, I can understand that those \"\\r\" at the end of\nevery line can be annoying.\n\nA simple _workaround_ would be to create one's own extra stylesheet,\nwith rule hiding control characters visualization (including \"\\r\"), e.g.\n\n  .cntrl { display: none; }\n\nand stuff thys additional it in @stylesheets via gitweb config file.\n\n> I have created a simple patch to avoid this.\n\nPlease read Documentation/SubmittingPatches if you want your work to\nbe considered for inclusion.  This is not a proper patch -- it lacks\ncommit message (comments should be outside of it, e.g. between \"---\"\nand diffstat) and signoff.\n\n> It adds just one line. I am not sure if the regexp should\n> contain 'g' switch in the end. Also, not sure if there should be some config\n> option to switch on/off this?\n\nNote that your patch beside hiding \"\\r\" in the case when file has\nWindows line endings, it also hides \"\\r\" in the case where file has\n_mixed_ line endings (LF mixed with CRLF, which is incorrect).  Though\nhandling that well would be quite difficult, I think...\n\nThough esc_html gets passed whole lines, I am not sure if it always\ngets passed whole lines and would continue getting passed only whole\nlines in the future, so there should be 'g' modifier (or better 'gm'\nmodifier to make sure that $ matches end of line not only end of\nstring).\n\nI think it would be better if there was an option to switch hiding\n\"\\r\" on and off... though I am not sure if it can be done without\nincuring large performance penalty.\n\n> ---\n>  gitweb/gitweb.perl |    1 +\n>  1 files changed, 1 insertions(+), 0 deletions(-)\n> \n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index abb5a79..92175bc 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -1500,6 +1500,7 @@ sub esc_html {\n>         if ($opts{'-nbsp'}) {\n>                 $str =~ s/ /&nbsp;/g;\n>         }\n> +       $str =~ s/\\r$//;\n>         $str =~ s|([[:cntrl:]])|(($1 ne \"\\t\") ? quot_cec($1) : $1)|eg;\n>         return $str;\n>  }\n> --\n\nAnother solution would be to modify quot_cec...\n\n-- \nJakub Narebski\n"},{"id":"183209","messageId":"7vvcnwybxj.fsf@alter.siamese.dyndns.org","threadId":"29455","inReplyTo":"m3aa58eskw.fsf@localhost.localdomain","subject":"Re: gitweb showing slash r at the end of line","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-27T23:15:36Z","receivedAt":"2012-01-27T23:15:36Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> Ondra Medek <xmedeko@gmail.com> writes:\n>\n>> we have gitweb running on Linux box. Some files have Windows line ending\n>> (CRLF) end we do not use core.autcrlf translation. gitweb show the last \\r\n>> in the end of each line, which is annoying.\n>\n> Well, this \"\\r\" allows to recognize when file with Windows line ending\n> (CRLF) made it into repository... which usually is discouraged.  But\n> if you allow this, I can understand that those \"\\r\" at the end of\n> every line can be annoying.\n\nI think the right thing to do is:\n\n * If the repository data is _supposed_ to have CRLF endings (e.g. check\n   with core.crlf or something), strip \\r and do not show them.\n\n * Otherwise, i.e. if the repository data is supposed _not_ to have CRLF\n   endings, do show these '\\r'.  Annoyance here is a *feature* to remind\n   the viewer that the contents needs _fixing_.\n\n * No other switches.\n"},{"id":"183225","messageId":"201201281802.44339.jnareb@gmail.com","threadId":"29455","inReplyTo":"7vvcnwybxj.fsf@alter.siamese.dyndns.org","subject":"Re: gitweb showing slash r at the end of line","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2012-01-28T17:02:43Z","receivedAt":"2012-01-28T17:02:43Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Sat, 28 Jan 2012, Junio C Hamano wrote:\n> Jakub Narebski <jnareb@gmail.com> writes:\n>> Ondra Medek <xmedeko@gmail.com> writes:\n>>\n>>> we have gitweb running on Linux box. Some files have Windows line ending\n>>> (CRLF) end we do not use core.autcrlf translation. gitweb show the last \\r\n>>> in the end of each line, which is annoying.\n>>\n>> Well, this \"\\r\" allows to recognize when file with Windows line ending\n>> (CRLF) made it into repository... which usually is discouraged.  But\n>> if you allow this, I can understand that those \"\\r\" at the end of\n>> every line can be annoying.\n> \n> I think the right thing to do is:\n> \n>  * If the repository data is _supposed_ to have CRLF endings (e.g. check\n>    with core.crlf or something), strip \\r and do not show them.\n> \n>  * Otherwise, i.e. if the repository data is supposed _not_ to have CRLF\n>    endings, do show these '\\r'.  Annoyance here is a *feature* to remind\n>    the viewer that the contents needs _fixing_.\n> \n>  * No other switches.\n\nI agree that it would be a bast solution if gitweb could automatically\ninfer whether CRLF is allowed (whitelist) or disallowed (blacklist) in\nfiles in given repository.  \n\nBut I am not sure if it is possible and what rules there should be for\na *BARE* repository; crlf and eol gitattributes and config variables\nare about what should appear in working area - something gitweb is not\ninterested in at all.\n\nIf gitweb code was structured in different way, we could check if all\nlines end in LF or all lines end in CRLF and add a note about that to\nfile or diff header, showing \"\\r\" only in case of mixed line endings...\nBut that's a futile wish, for now at least.\n\n-- \nJakub Narebski\nPoland\n"},{"id":"183289","messageId":"1327910140526-7235866.post@n2.nabble.com","threadId":"29455","inReplyTo":"201201281802.44339.jnareb@gmail.com","subject":"Re: gitweb showing slash r at the end of line","fromName":"Ondra Medek","fromEmail":"xmedeko@gmail.com","sentAt":"2012-01-30T07:55:40Z","receivedAt":"2012-01-30T07:55:40Z","isPatch":false,"sender":{"key":"xmedeko@gmail.com","avatar":"https://gravatar.com/avatar/09ec305680e81ade2e3617fd245cda7136f6d5e859b5120feb9436e0725f6e1d?d=mp&s=160"},"body":"Hi Jakub,\nI have read \"SubmittingPatches\". I have made a path by \"git format-patch -M\"\nand I have though it's enough. The problem maybe was, that I had not\nincluded \"Subject: \" from the result of \"git format-patch -M\". Next time I\nwill try to do it better.\n\nI am a Git newbie, but my bare repos have \"config\" file and this file can\ncontain the \"core.autocrlf\" setting. So the gitweb can read it. Or what\nabout to have a special section [gitweb] in this config? For now, the gitweb\nconfig files are somewhat \"scattered\" = \"descrition\", \"cloneurl\",\n\"project.list\", ...\n\nYeah, the autodetection of mixed mode line endings could be the best\nsolution.\n\nHowever, from my point of view a global gitweb setting would be enough for\nnow.\n\n\n--\nView this message in context: http://git.661346.n2.nabble.com/gitweb-showing-slash-r-at-the-end-of-line-tp7229895p7235866.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"183295","messageId":"m3obtlczmu.fsf@localhost.localdomain","threadId":"29455","inReplyTo":"1327910140526-7235866.post@n2.nabble.com","subject":"Re: gitweb showing slash r at the end of line","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2012-01-30T09:23:05Z","receivedAt":"2012-01-30T09:23:05Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Ondra Medek <xmedeko@gmail.com> writes:\n\n> I have read \"SubmittingPatches\". I have made a path by \"git format-patch -M\"\n> and I have though it's enough. The problem maybe was, that I had not\n> included \"Subject: \" from the result of \"git format-patch -M\". Next time I\n> will try to do it better.\n\nThe problem is that in place of proper commit message, describing\nchange for posteriority as described in SubmittingPatches, you have an\nemail describing why you created this commit:\n\nOM> Hi,\nOM> we have gitweb running on Linux box. Some files have Windows line ending\nOM> (CRLF) end we do not use core.autcrlf translation. gitweb show the last \\r\nOM> in the end of each line, which is annoying. I have creates a simple patch to\nOM> avoid this. It adds just one line. I am not sure if the regexp should\nOM> contain 'g' switch in the end. Also, not sure if there shoul be some config\nOM> option to switch on/off this?\nOM> \nOM> Cheers\nOM> Ondra\n \nTake a look how other commit messages are written in git.git, and\nplease remember to sign off your patches.\n\n> I am a Git newbie, but my bare repos have \"config\" file and this file can\n> contain the \"core.autocrlf\" setting. So the gitweb can read it. Or what\n> about to have a special section [gitweb] in this config? For now, the gitweb\n> config files are somewhat \"scattered\" = \"descrition\", \"cloneurl\",\n> \"project.list\", ...\n\nThe [gitweb] section contains stuff that can be used instead of\nindividual files like 'description' ('gitweb.description' can be used\ninstead if that file is not present), and also to configure\noverridable features on per-repository basis, like 'gitweb.snapshot'.\n \n> Yeah, the autodetection of mixed mode line endings could be the best\n> solution.\n> \n> However, from my point of view a global gitweb setting would be enough for\n> now.\n\nI think that if not using autodetection this should be made into\nproper gitweb %feature, e.g. named 'eol' - this automatically gives\nability to override it on per-repository basis via repo config.\n\n-- \nJakub Narebski\n"},{"id":"183332","messageId":"1327939743099-7237025.post@n2.nabble.com","threadId":"29455","inReplyTo":"m3obtlczmu.fsf@localhost.localdomain","subject":"Re: gitweb showing slash r at the end of line","fromName":"Ondra Medek","fromEmail":"xmedeko@gmail.com","sentAt":"2012-01-30T16:09:03Z","receivedAt":"2012-01-30T16:09:03Z","isPatch":false,"sender":{"key":"xmedeko@gmail.com","avatar":"https://gravatar.com/avatar/09ec305680e81ade2e3617fd245cda7136f6d5e859b5120feb9436e0725f6e1d?d=mp&s=160"},"body":"Thanks for pointing out the [gitweb] section of the config. Should I try to\nmake the patch or someone else more skilled would pick this up?\n\nCheers\nOndra\n\n--\nView this message in context: http://git.661346.n2.nabble.com/gitweb-showing-slash-r-at-the-end-of-line-tp7229895p7237025.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"183648","messageId":"m339atc880.fsf@localhost.localdomain","threadId":"29455","inReplyTo":"1327939743099-7237025.post@n2.nabble.com","subject":"Re: gitweb showing slash r at the end of line","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2012-02-02T20:04:06Z","receivedAt":"2012-02-02T20:04:06Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Ondra Medek <xmedeko@gmail.com> writes:\n\n> Thanks for pointing out the [gitweb] section of the config. Should I try to\n> make the patch or someone else more skilled would pick this up?\n\nI'll try to pick it up, if you wouldn't be able to...\n\n...subject to finding time for this, of course.\n\n-- \nJakub Narebski\n"}]}