* [PATCH 0/3] minor gitweb modifications @ 2010-12-16 21:43 Sylvain Rabot 2010-12-16 21:43 ` [PATCH 1/3] gitweb: add extensions to highlight feature Sylvain Rabot ` (2 more replies) 0 siblings, 3 replies; 12+ messages in thread From: Sylvain Rabot @ 2010-12-16 21:43 UTC (permalink / raw) To: git; +Cc: Sylvain Rabot Hi, here a three patch serie with minor updates for gitweb based on master. I'm not really fond of the third patch but it solves a problem I've encountered on several files. Regards. Sylvain Rabot (3): gitweb: add extensions to highlight feature gitweb: decorate a bit more remotes gitweb: remove test when closing file descriptor gitweb/gitweb.perl | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-) -- 1.7.3.2 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/3] gitweb: add extensions to highlight feature 2010-12-16 21:43 [PATCH 0/3] minor gitweb modifications Sylvain Rabot @ 2010-12-16 21:43 ` Sylvain Rabot 2010-12-16 22:22 ` Jakub Narebski 2010-12-16 21:43 ` [PATCH 2/3] gitweb: decorate a bit more remotes Sylvain Rabot 2010-12-16 21:43 ` [PATCH 3/3] gitweb: remove test when closing file descriptor Sylvain Rabot 2 siblings, 1 reply; 12+ messages in thread From: Sylvain Rabot @ 2010-12-16 21:43 UTC (permalink / raw) To: git; +Cc: Sylvain Rabot added: sql, php5, phps, bash, zsh, mk Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr> --- gitweb/gitweb.perl | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index d521c93..db18d06 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -250,13 +250,14 @@ our %highlight_ext = ( # main extensions, defining name of syntax; # see files in /usr/share/highlight/langDefs/ directory map { $_ => $_ } - qw(py c cpp rb java css php sh pl js tex bib xml awk bat ini spec tcl), + qw(py c cpp rb java css php pl js tex bib xml awk bat ini spec tcl sql), # alternate extensions, see /etc/highlight/filetypes.conf 'h' => 'c', + map { $_ => 'sh' } qw(bash zsh), map { $_ => 'cpp' } qw(cxx c++ cc), - map { $_ => 'php' } qw(php3 php4), + map { $_ => 'php' } qw(php3 php4 php5 phps), map { $_ => 'pl' } qw(perl pm), # perhaps also 'cgi' - 'mak' => 'make', + map { $_ => 'make'} qw(mak mk), map { $_ => 'xml' } qw(xhtml html htm), ); -- 1.7.3.2 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] gitweb: add extensions to highlight feature 2010-12-16 21:43 ` [PATCH 1/3] gitweb: add extensions to highlight feature Sylvain Rabot @ 2010-12-16 22:22 ` Jakub Narebski 2010-12-16 22:33 ` Sylvain Rabot 0 siblings, 1 reply; 12+ messages in thread From: Jakub Narebski @ 2010-12-16 22:22 UTC (permalink / raw) To: Sylvain Rabot; +Cc: git, Jakub Narebski Sylvain Rabot <sylvain@abstraction.fr> writes: > added: sql, php5, phps, bash, zsh, mk > There is one issue with this patch (see below), but otherwise I like it. > Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr> > --- > gitweb/gitweb.perl | 7 ++++--- > 1 files changed, 4 insertions(+), 3 deletions(-) > > diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl > index d521c93..db18d06 100755 > --- a/gitweb/gitweb.perl > +++ b/gitweb/gitweb.perl > @@ -250,13 +250,14 @@ our %highlight_ext = ( > # main extensions, defining name of syntax; > # see files in /usr/share/highlight/langDefs/ directory > map { $_ => $_ } > - qw(py c cpp rb java css php sh pl js tex bib xml awk bat ini spec tcl), > + qw(py c cpp rb java css php pl js tex bib xml awk bat ini spec tcl sql), Why did you remove 'sh' => 'sh' mapping? Shouldn't it be - qw(py c cpp rb java css php sh pl js tex bib xml awk bat ini spec tcl), + qw(py c cpp rb java css php sh pl js tex bib xml awk bat ini spec tcl sql), > # alternate extensions, see /etc/highlight/filetypes.conf > 'h' => 'c', > + map { $_ => 'sh' } qw(bash zsh), Good idea. > map { $_ => 'cpp' } qw(cxx c++ cc), > - map { $_ => 'php' } qw(php3 php4), > + map { $_ => 'php' } qw(php3 php4 php5 phps), Good idea. > map { $_ => 'pl' } qw(perl pm), # perhaps also 'cgi' > - 'mak' => 'make', > + map { $_ => 'make'} qw(mak mk), Good idea. Sidenote: git itself uses *.mak extension. Is *.mk popular? > map { $_ => 'xml' } qw(xhtml html htm), > ); > > -- > 1.7.3.2 > -- Jakub Narebski Poland ShadeHawk on #git ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] gitweb: add extensions to highlight feature 2010-12-16 22:22 ` Jakub Narebski @ 2010-12-16 22:33 ` Sylvain Rabot 2010-12-17 11:17 ` Jakub Narebski 0 siblings, 1 reply; 12+ messages in thread From: Sylvain Rabot @ 2010-12-16 22:33 UTC (permalink / raw) To: Jakub Narebski; +Cc: git [-- Attachment #1: Type: text/plain, Size: 2089 bytes --] On Thu, 2010-12-16 at 14:22 -0800, Jakub Narebski wrote: > Sylvain Rabot <sylvain@abstraction.fr> writes: > > > added: sql, php5, phps, bash, zsh, mk > > > > There is one issue with this patch (see below), but otherwise I like > it. > > > Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr> > > --- > > gitweb/gitweb.perl | 7 ++++--- > > 1 files changed, 4 insertions(+), 3 deletions(-) > > > > diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl > > index d521c93..db18d06 100755 > > --- a/gitweb/gitweb.perl > > +++ b/gitweb/gitweb.perl > > @@ -250,13 +250,14 @@ our %highlight_ext = ( > > # main extensions, defining name of syntax; > > # see files in /usr/share/highlight/langDefs/ directory > > map { $_ => $_ } > > - qw(py c cpp rb java css php sh pl js tex bib xml awk bat ini spec tcl), > > + qw(py c cpp rb java css php pl js tex bib xml awk bat ini spec tcl sql), > > Why did you remove 'sh' => 'sh' mapping? Shouldn't it be > > - qw(py c cpp rb java css php sh pl js tex bib xml awk bat ini spec tcl), > + qw(py c cpp rb java css php sh pl js tex bib xml awk bat ini spec tcl sql), > I removed it on purpose but should have not, I was thinking the mapping made below would be enough but no, you're right. > > # alternate extensions, see /etc/highlight/filetypes.conf > > 'h' => 'c', > > + map { $_ => 'sh' } qw(bash zsh), > > Good idea. Does ksh, csh can be highlighted as sh too ? > > > map { $_ => 'cpp' } qw(cxx c++ cc), > > - map { $_ => 'php' } qw(php3 php4), > > + map { $_ => 'php' } qw(php3 php4 php5 phps), > > Good idea. > > > map { $_ => 'pl' } qw(perl pm), # perhaps also 'cgi' > > - 'mak' => 'make', > > + map { $_ => 'make'} qw(mak mk), > > Good idea. > > Sidenote: git itself uses *.mak extension. Is *.mk popular? Don't know but mk is mapped to Makefiles in the gtksourceview lib so I added it here. > > > map { $_ => 'xml' } qw(xhtml html htm), > > ); > > > > -- > > 1.7.3.2 > > > -- Sylvain Rabot <sylvain@abstraction.fr> [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 490 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] gitweb: add extensions to highlight feature 2010-12-16 22:33 ` Sylvain Rabot @ 2010-12-17 11:17 ` Jakub Narebski 0 siblings, 0 replies; 12+ messages in thread From: Jakub Narebski @ 2010-12-17 11:17 UTC (permalink / raw) To: Sylvain Rabot; +Cc: git On Thu, 16 Dec 2010, Sylvain Rabot wrote: > On Thu, 2010-12-16 at 14:22 -0800, Jakub Narebski wrote: > > Sylvain Rabot <sylvain@abstraction.fr> writes: > > > # alternate extensions, see /etc/highlight/filetypes.conf > > > 'h' => 'c', > > > + map { $_ => 'sh' } qw(bash zsh), > > > > Good idea. > > Does ksh, csh can be highlighted as sh too ? My /etc/highlight/filetypes.conf does include only $ext(sh)=bash All of bash, zsh and ksh are POSIX shell (sh) compatibile, so sh syntax (which is according to my /usr/share/highlight/langDefs/sh.lang file "Bash script language definition file" ;-)) should work. csh IIRC isn't. So therefore I am not sure if csh can be highlighted correctly using sh syntax. -- Jakub Narebski Poland ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 2/3] gitweb: decorate a bit more remotes 2010-12-16 21:43 [PATCH 0/3] minor gitweb modifications Sylvain Rabot 2010-12-16 21:43 ` [PATCH 1/3] gitweb: add extensions to highlight feature Sylvain Rabot @ 2010-12-16 21:43 ` Sylvain Rabot 2010-12-16 22:23 ` Jakub Narebski 2010-12-16 21:43 ` [PATCH 3/3] gitweb: remove test when closing file descriptor Sylvain Rabot 2 siblings, 1 reply; 12+ messages in thread From: Sylvain Rabot @ 2010-12-16 21:43 UTC (permalink / raw) To: git; +Cc: Sylvain Rabot Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr> --- gitweb/gitweb.perl | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index db18d06..9398475 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -5127,13 +5127,13 @@ sub git_remote_block { if (defined $fetch) { if ($fetch eq $push) { - $urls_table .= format_repo_url("URL", $fetch); + $urls_table .= format_repo_url("<strong>URL:</strong>", $fetch); } else { - $urls_table .= format_repo_url("Fetch URL", $fetch); - $urls_table .= format_repo_url("Push URL", $push) if defined $push; + $urls_table .= format_repo_url("<strong>Fetch URL:</strong>", $fetch); + $urls_table .= format_repo_url("<strong>Push URL:</strong>", $push) if defined $push; } } elsif (defined $push) { - $urls_table .= format_repo_url("Push URL", $push); + $urls_table .= format_repo_url("<strong>Push URL:</strong>", $push); } else { $urls_table .= format_repo_url("", "No remote URL"); } -- 1.7.3.2 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] gitweb: decorate a bit more remotes 2010-12-16 21:43 ` [PATCH 2/3] gitweb: decorate a bit more remotes Sylvain Rabot @ 2010-12-16 22:23 ` Jakub Narebski 2010-12-20 12:04 ` Drew Northup 0 siblings, 1 reply; 12+ messages in thread From: Jakub Narebski @ 2010-12-16 22:23 UTC (permalink / raw) To: Sylvain Rabot; +Cc: git, Jakub Narebski Sylvain Rabot <sylvain@abstraction.fr> writes: > Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr> > --- > gitweb/gitweb.perl | 8 ++++---- > 1 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl > index db18d06..9398475 100755 > --- a/gitweb/gitweb.perl > +++ b/gitweb/gitweb.perl > @@ -5127,13 +5127,13 @@ sub git_remote_block { > > if (defined $fetch) { > if ($fetch eq $push) { > - $urls_table .= format_repo_url("URL", $fetch); > + $urls_table .= format_repo_url("<strong>URL:</strong>", $fetch); I would really prefer to use CSS for that... -- Jakub Narebski Poland ShadeHawk on #git ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] gitweb: decorate a bit more remotes 2010-12-16 22:23 ` Jakub Narebski @ 2010-12-20 12:04 ` Drew Northup 0 siblings, 0 replies; 12+ messages in thread From: Drew Northup @ 2010-12-20 12:04 UTC (permalink / raw) To: Jakub Narebski; +Cc: Sylvain Rabot, git On Thu, 2010-12-16 at 14:23 -0800, Jakub Narebski wrote: > Sylvain Rabot <sylvain@abstraction.fr> writes: > > > Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr> > > --- > > gitweb/gitweb.perl | 8 ++++---- > > 1 files changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl > > index db18d06..9398475 100755 > > --- a/gitweb/gitweb.perl > > +++ b/gitweb/gitweb.perl > > @@ -5127,13 +5127,13 @@ sub git_remote_block { > > > > if (defined $fetch) { > > if ($fetch eq $push) { > > - $urls_table .= format_repo_url("URL", $fetch); > > + $urls_table .= format_repo_url("<strong>URL:</strong>", $fetch); > > I would really prefer to use CSS for that... Agreed; <span class="repo_url">URL:</span> is far more appropriate in my opinion. -- -Drew Northup N1XIM AKA RvnPhnx on OPN ________________________________________________ "As opposed to vegetable or mineral error?" -John Pescatore, SANS NewsBites Vol. 12 Num. 59 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/3] gitweb: remove test when closing file descriptor 2010-12-16 21:43 [PATCH 0/3] minor gitweb modifications Sylvain Rabot 2010-12-16 21:43 ` [PATCH 1/3] gitweb: add extensions to highlight feature Sylvain Rabot 2010-12-16 21:43 ` [PATCH 2/3] gitweb: decorate a bit more remotes Sylvain Rabot @ 2010-12-16 21:43 ` Sylvain Rabot 2010-12-16 22:30 ` Jakub Narebski 2 siblings, 1 reply; 12+ messages in thread From: Sylvain Rabot @ 2010-12-16 21:43 UTC (permalink / raw) To: git; +Cc: Sylvain Rabot it happens that closing file descriptor fails whereas the blob is perfectly readable. Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr> --- gitweb/gitweb.perl | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 9398475..9a885b1 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -3450,8 +3450,7 @@ sub run_highlighter { my ($fd, $highlight, $syntax) = @_; return $fd unless ($highlight && defined $syntax); - close $fd - or die_error(404, "Reading blob failed"); + close $fd; open $fd, quote_command(git_cmd(), "cat-file", "blob", $hash)." | ". quote_command($highlight_bin). " --xhtml --fragment --syntax $syntax |" -- 1.7.3.2 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] gitweb: remove test when closing file descriptor 2010-12-16 21:43 ` [PATCH 3/3] gitweb: remove test when closing file descriptor Sylvain Rabot @ 2010-12-16 22:30 ` Jakub Narebski 2010-12-16 22:37 ` Sylvain Rabot 0 siblings, 1 reply; 12+ messages in thread From: Jakub Narebski @ 2010-12-16 22:30 UTC (permalink / raw) To: Sylvain Rabot; +Cc: git, Jakub Narebski Sylvain Rabot <sylvain@abstraction.fr> writes: > it happens that closing file descriptor fails whereas > the blob is perfectly readable. > > Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr> > --- > gitweb/gitweb.perl | 3 +-- > 1 files changed, 1 insertions(+), 2 deletions(-) > > diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl > index 9398475..9a885b1 100755 > --- a/gitweb/gitweb.perl > +++ b/gitweb/gitweb.perl > @@ -3450,8 +3450,7 @@ sub run_highlighter { > my ($fd, $highlight, $syntax) = @_; > return $fd unless ($highlight && defined $syntax); > > - close $fd > - or die_error(404, "Reading blob failed"); > + close $fd; Actually what I think happens is the following. "close $fh" cannot usually fail, unless (`perldoc -f close`): If the file handle came from a piped open, "close" will additionally return false if one of the other system calls involved fails, or if the program exits with non-zero status. (If the only problem was that the program exited non-zero, $! will be set to 0.) Closing a pipe also waits for the process executing on the pipe to complete, in case you want to look at the output of the pipe afterwards, and implicitly puts the exit status value of that command into $?. Prematurely closing the read end of a pipe (i.e. before the process writ- ing to it at the other end has closed it) will result in a SIGPIPE being delivered to the writer. If the other end can't handle that, be sure to read all the data before closing the pipe. In this place we close read end of pipe after at most reading a few bytes (what -T test does), so what might happen is that writer got SIGPIPE and "failed". But we are not interested in this, so we can safely ignore return from 'close'. I think that some from above explanation should make it to commit message. > open $fd, quote_command(git_cmd(), "cat-file", "blob", $hash)." | ". > quote_command($highlight_bin). > " --xhtml --fragment --syntax $syntax |" P.S. A better solution would be to redirect opened $fd to highlighter, instead of closing and reopening a pipe... but I'm not sure how it could be implemented. -- Jakub Narebski Poland ShadeHawk on #git ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] gitweb: remove test when closing file descriptor 2010-12-16 22:30 ` Jakub Narebski @ 2010-12-16 22:37 ` Sylvain Rabot 2010-11-16 23:02 ` Jakub Narebski 0 siblings, 1 reply; 12+ messages in thread From: Sylvain Rabot @ 2010-12-16 22:37 UTC (permalink / raw) To: Jakub Narebski; +Cc: git [-- Attachment #1: Type: text/plain, Size: 2599 bytes --] On Thu, 2010-12-16 at 14:30 -0800, Jakub Narebski wrote: > Sylvain Rabot <sylvain@abstraction.fr> writes: > > > it happens that closing file descriptor fails whereas > > the blob is perfectly readable. > > > > Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr> > > --- > > gitweb/gitweb.perl | 3 +-- > > 1 files changed, 1 insertions(+), 2 deletions(-) > > > > diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl > > index 9398475..9a885b1 100755 > > --- a/gitweb/gitweb.perl > > +++ b/gitweb/gitweb.perl > > @@ -3450,8 +3450,7 @@ sub run_highlighter { > > my ($fd, $highlight, $syntax) = @_; > > return $fd unless ($highlight && defined $syntax); > > > > - close $fd > > - or die_error(404, "Reading blob failed"); > > + close $fd; > > Actually what I think happens is the following. "close $fh" cannot > usually fail, unless (`perldoc -f close`): > > If the file handle came from a piped open, "close" will additionally > return false if one of the other system calls involved fails, or if the > program exits with non-zero status. (If the only problem was that the > program exited non-zero, $! will be set to 0.) Closing a pipe also waits > for the process executing on the pipe to complete, in case you want to > look at the output of the pipe afterwards, and implicitly puts the exit > status value of that command into $?. > > Prematurely closing the read end of a pipe (i.e. before the process writ- > ing to it at the other end has closed it) will result in a SIGPIPE being > delivered to the writer. If the other end can't handle that, be sure to > read all the data before closing the pipe. > > In this place we close read end of pipe after at most reading a few > bytes (what -T test does), so what might happen is that writer got > SIGPIPE and "failed". But we are not interested in this, so we can > safely ignore return from 'close'. > > I think that some from above explanation should make it to commit > message. Thanks for explaining it, I did not have any idea why it was failing. Can I use your explanation as commit message ? > > > open $fd, quote_command(git_cmd(), "cat-file", "blob", $hash)." | ". > > quote_command($highlight_bin). > > " --xhtml --fragment --syntax $syntax |" > > P.S. A better solution would be to redirect opened $fd to highlighter, > instead of closing and reopening a pipe... but I'm not sure how it > could be implemented. I don't know either. > -- Sylvain Rabot <sylvain@abstraction.fr> [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 490 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] gitweb: remove test when closing file descriptor 2010-12-16 22:37 ` Sylvain Rabot @ 2010-11-16 23:02 ` Jakub Narebski 0 siblings, 0 replies; 12+ messages in thread From: Jakub Narebski @ 2010-11-16 23:02 UTC (permalink / raw) To: Sylvain Rabot; +Cc: git On Thu, 16 Dec 2010, Sylvain Rabot wrote: > On Thu, 2010-12-16 at 14:30 -0800, Jakub Narebski wrote: > > Sylvain Rabot <sylvain@abstraction.fr> writes: > > > > > it happens that closing file descriptor fails whereas > > > the blob is perfectly readable. > > > > > > Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr> > > > --- [...] > > > - close $fd > > > - or die_error(404, "Reading blob failed"); > > > + close $fd; [...] > > In this place we close read end of pipe after at most reading a few > > bytes (what -T test does), so what might happen is that writer got > > SIGPIPE and "failed". But we are not interested in this, so we can > > safely ignore return from 'close'. > > > > I think that some from above explanation should make it to commit > > message. > > Thanks for explaining it, I did not have any idea why it was failing. > Can I use your explanation as commit message ? Of course. Though I am not sure if it is really the reason, it looks reasonable. -- Jakub Narebski Poland ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2010-12-20 12:05 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-12-16 21:43 [PATCH 0/3] minor gitweb modifications Sylvain Rabot 2010-12-16 21:43 ` [PATCH 1/3] gitweb: add extensions to highlight feature Sylvain Rabot 2010-12-16 22:22 ` Jakub Narebski 2010-12-16 22:33 ` Sylvain Rabot 2010-12-17 11:17 ` Jakub Narebski 2010-12-16 21:43 ` [PATCH 2/3] gitweb: decorate a bit more remotes Sylvain Rabot 2010-12-16 22:23 ` Jakub Narebski 2010-12-20 12:04 ` Drew Northup 2010-12-16 21:43 ` [PATCH 3/3] gitweb: remove test when closing file descriptor Sylvain Rabot 2010-12-16 22:30 ` Jakub Narebski 2010-12-16 22:37 ` Sylvain Rabot 2010-11-16 23:02 ` Jakub Narebski
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).