git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: Ondra Medek <xmedeko@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: gitweb showing slash r at the end of line
Date: Fri, 27 Jan 2012 13:35:45 -0800 (PST)	[thread overview]
Message-ID: <m3aa58eskw.fsf@localhost.localdomain> (raw)
In-Reply-To: <1327673954458-7229895.post@n2.nabble.com>

Ondra Medek <xmedeko@gmail.com> writes:

> we have gitweb running on Linux box. Some files have Windows line ending
> (CRLF) end we do not use core.autcrlf translation. gitweb show the last \r
> in the end of each line, which is annoying.

Well, this "\r" allows to recognize when file with Windows line ending
(CRLF) made it into repository... which usually is discouraged.  But
if you allow this, I can understand that those "\r" at the end of
every line can be annoying.

A simple _workaround_ would be to create one's own extra stylesheet,
with rule hiding control characters visualization (including "\r"), e.g.

  .cntrl { display: none; }

and stuff thys additional it in @stylesheets via gitweb config file.

> I have created a simple patch to avoid this.

Please read Documentation/SubmittingPatches if you want your work to
be considered for inclusion.  This is not a proper patch -- it lacks
commit message (comments should be outside of it, e.g. between "---"
and diffstat) and signoff.

> It adds just one line. I am not sure if the regexp should
> contain 'g' switch in the end. Also, not sure if there should be some config
> option to switch on/off this?

Note that your patch beside hiding "\r" in the case when file has
Windows line endings, it also hides "\r" in the case where file has
_mixed_ line endings (LF mixed with CRLF, which is incorrect).  Though
handling that well would be quite difficult, I think...

Though esc_html gets passed whole lines, I am not sure if it always
gets passed whole lines and would continue getting passed only whole
lines in the future, so there should be 'g' modifier (or better 'gm'
modifier to make sure that $ matches end of line not only end of
string).

I think it would be better if there was an option to switch hiding
"\r" on and off... though I am not sure if it can be done without
incuring large performance penalty.

> ---
>  gitweb/gitweb.perl |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index abb5a79..92175bc 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -1500,6 +1500,7 @@ sub esc_html {
>         if ($opts{'-nbsp'}) {
>                 $str =~ s/ /&nbsp;/g;
>         }
> +       $str =~ s/\r$//;
>         $str =~ s|([[:cntrl:]])|(($1 ne "\t") ? quot_cec($1) : $1)|eg;
>         return $str;
>  }
> --

Another solution would be to modify quot_cec...

-- 
Jakub Narebski

  reply	other threads:[~2012-01-27 21:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-27 14:19 gitweb showing slash r at the end of line Ondra Medek
2012-01-27 21:35 ` Jakub Narebski [this message]
2012-01-27 23:15   ` Junio C Hamano
2012-01-28 17:02     ` Jakub Narebski
2012-01-30  7:55       ` Ondra Medek
2012-01-30  9:23         ` Jakub Narebski
2012-01-30 16:09           ` Ondra Medek
2012-02-02 20:04             ` Jakub Narebski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3aa58eskw.fsf@localhost.localdomain \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=xmedeko@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).