# [PATCH 0/3 v3] minor gitweb modifications

6 messages from 2010-12-29 to 2010-12-29. Participants: Sylvain Rabot, Jakub Narebski.
Thread: https://gitlist.dev/t/26157

## Sylvain Rabot, 2010-12-29 19:33

Subject: [PATCH 0/3 v3] minor gitweb modifications
Message-ID: <1293651215-4924-1-git-send-email-sylvain@abstraction.fr>
URL: https://gitlist.dev/e/1293651215-4924-1-git-send-email-sylvain%40abstraction.fr

```
here a three patch serie with minor updates for gitweb based on master.

This serie has been improved regarding the comments of :

 - Jakub Narebski <jnareb@gmail.com>
 - Jonathan Nieder <jrnieder@gmail.com>

Regards.

Sylvain Rabot (3):
  gitweb: add extensions to highlight feature
  gitweb: remove test when closing file descriptor
  gitweb: add css class to remote url titles

 gitweb/gitweb.perl       |   18 +++++++++---------
 gitweb/static/gitweb.css |    5 +++++
 2 files changed, 14 insertions(+), 9 deletions(-)

-- 
1.7.3.4.523.g72f0d.dirty

```

## Sylvain Rabot, 2010-12-29 19:33

Subject: [PATCH 1/3] gitweb: add extensions to highlight feature
Message-ID: <1293651215-4924-2-git-send-email-sylvain@abstraction.fr>
URL: https://gitlist.dev/e/1293651215-4924-2-git-send-email-sylvain%40abstraction.fr
In-Reply-To: <1293651215-4924-1-git-send-email-sylvain@abstraction.fr>

```
added: sql, php5, phps, bash, zsh, ksh, mk, make

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 4779618..ea984b9 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 sh pl js tex bib xml awk bat ini spec tcl sql make),
 	# alternate extensions, see /etc/highlight/filetypes.conf
 	'h' => 'c',
+	map { $_ => 'sh'  } qw(bash zsh ksh),
 	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.4.523.g72f0d.dirty

```

## Sylvain Rabot, 2010-12-29 19:33

Subject: [PATCH 2/3] gitweb: remove test when closing file descriptor
Message-ID: <1293651215-4924-3-git-send-email-sylvain@abstraction.fr>
URL: https://gitlist.dev/e/1293651215-4924-3-git-send-email-sylvain%40abstraction.fr
In-Reply-To: <1293651215-4924-1-git-send-email-sylvain@abstraction.fr>

```
it happens that closing file descriptor fails whereas
the blob is perfectly readable. According to perlman
the reasons could be:

   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 case we don't mind that close fails.

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 ea984b9..eae75ac 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3465,8 +3465,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.4.523.g72f0d.dirty

```

## Sylvain Rabot, 2010-12-29 19:33

Subject: [PATCH 3/3] gitweb: add css class to remote url titles
Message-ID: <1293651215-4924-4-git-send-email-sylvain@abstraction.fr>
URL: https://gitlist.dev/e/1293651215-4924-4-git-send-email-sylvain%40abstraction.fr
In-Reply-To: <1293651215-4924-1-git-send-email-sylvain@abstraction.fr>

```
Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr>
---
 gitweb/gitweb.perl       |    8 ++++----
 gitweb/static/gitweb.css |    5 +++++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index eae75ac..cb169c7 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -5146,13 +5146,13 @@ sub git_remote_block {
 
 	if (defined $fetch) {
 		if ($fetch eq $push) {
-			$urls_table .= format_repo_url("URL", $fetch);
+			$urls_table .= format_repo_url("<span class=\"metadata_remote_fetch_url\">URL</span>", $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("<span class=\"metadata_remote_fetch_url\">Fetch URL</span>", $fetch);
+			$urls_table .= format_repo_url("<span class=\"metadata_remote_push_url\">Push URL</span>", $push) if defined $push;
 		}
 	} elsif (defined $push) {
-		$urls_table .= format_repo_url("Push URL", $push);
+		$urls_table .= format_repo_url("<span class=\"metadata_remote_push_url\">Push URL</span>", $push);
 	} else {
 		$urls_table .= format_repo_url("", "No remote URL");
 	}
diff --git a/gitweb/static/gitweb.css b/gitweb/static/gitweb.css
index 79d7eeb..631b20d 100644
--- a/gitweb/static/gitweb.css
+++ b/gitweb/static/gitweb.css
@@ -579,6 +579,11 @@ div.remote {
 	display: inline-block;
 }
 
+.metadata_remote_fetch_url,
+.metadata_remote_push_url {
+	font-weight: bold;
+}
+
 /* Style definition generated by highlight 2.4.5, http://www.andre-simon.de/ */
 
 /* Highlighting theme definition: */
-- 
1.7.3.4.523.g72f0d.dirty

```

## Jakub Narebski, 2010-12-29 22:41

Subject: Re: [PATCH 0/3 v3] minor gitweb modifications
Message-ID: <m3fwtgcido.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m3fwtgcido.fsf%40localhost.localdomain
In-Reply-To: <1293651215-4924-1-git-send-email-sylvain@abstraction.fr>

```
Sylvain Rabot <sylvain@abstraction.fr> writes:

> here a three patch serie with minor updates for gitweb based on master.
> 
> This serie has been improved regarding the comments of :
> 
>  - Jakub Narebski <jnareb@gmail.com>
>  - Jonathan Nieder <jrnieder@gmail.com>
> 
> Regards.

A few comments, in this version about commit messages, not the code:
 
> Sylvain Rabot (3):
>   gitweb: add extensions to highlight feature

It is about adding support for supporting additional file extensions
for syntax highlighting, not about extending the highlight feature or
adding some plugin thingy to it, as one can think on first read.

>   gitweb: remove test when closing file descriptor

It is about closing open pipe (file descriptor) without checking for
error in the case where we don't care about errors in the caller; in
short about not testing status of closing filehandle in git_highlight

>   gitweb: add css class to remote url titles

It is about distinguishing visually type of link using styles; adding
CSS class is just a way to do it.

This actually has few comments about code.

> 
>  gitweb/gitweb.perl       |   18 +++++++++---------
>  gitweb/static/gitweb.css |    5 +++++
>  2 files changed, 14 insertions(+), 9 deletions(-)
> 
> -- 
> 1.7.3.4.523.g72f0d.dirty
> 

-- 
Jakub Narebski
Poland
ShadeHawk on #git

```

## Jakub Narebski, 2010-12-29 22:44

Subject: Re: [PATCH 3/3] gitweb: add css class to remote url titles
Message-ID: <m3bp44ci8p.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m3bp44ci8p.fsf%40localhost.localdomain
In-Reply-To: <1293651215-4924-4-git-send-email-sylvain@abstraction.fr>

```
Sylvain Rabot <sylvain@abstraction.fr> writes:

> Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr>
> ---
>  gitweb/gitweb.perl       |    8 ++++----
>  gitweb/static/gitweb.css |    5 +++++
>  2 files changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index eae75ac..cb169c7 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -5146,13 +5146,13 @@ sub git_remote_block {
>  
>  	if (defined $fetch) {
>  		if ($fetch eq $push) {
> -			$urls_table .= format_repo_url("URL", $fetch);
> +			$urls_table .= format_repo_url("<span class=\"metadata_remote_fetch_url\">URL</span>", $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("<span class=\"metadata_remote_fetch_url\">Fetch URL</span>", $fetch);
> +			$urls_table .= format_repo_url("<span class=\"metadata_remote_push_url\">Push URL</span>", $push) if defined $push;
>  		}
>  	} elsif (defined $push) {
> -		$urls_table .= format_repo_url("Push URL", $push);
> +		$urls_table .= format_repo_url("<span class=\"metadata_remote_push_url\">Push URL</span>", $push);
>  	} else {
>  		$urls_table .= format_repo_url("", "No remote URL");
>  	}

I'm not sure if in this situation if it would not be better to extend
format_repo_url subroutine to take additional parameter describing
_type_ of repo URL; it then would do styling internally.  Which means
moving wrapping 'URL', 'Fetch URL' etc. in span element to
format_repo_url from the caller.

> diff --git a/gitweb/static/gitweb.css b/gitweb/static/gitweb.css
> index 79d7eeb..631b20d 100644
> --- a/gitweb/static/gitweb.css
> +++ b/gitweb/static/gitweb.css
> @@ -579,6 +579,11 @@ div.remote {
>  	display: inline-block;
>  }
>  
> +.metadata_remote_fetch_url,
> +.metadata_remote_push_url {
> +	font-weight: bold;
> +}
> +

Good!

-- 
Jakub Narebski
Poland
ShadeHawk on #git

```
