git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: "Sébastien Cevey" <seb@cine7.net>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
	Petr Baudis <pasky@suse.cz>,
	Gustavo Sverzut Barbieri <barbieri@profusion.mobi>
Subject: Re: [PATCH v3 1/3] gitweb: Modularized git_get_project_description to be more generic
Date: Fri, 5 Dec 2008 02:38:14 +0100	[thread overview]
Message-ID: <200812050238.16018.jnareb@gmail.com> (raw)
In-Reply-To: <87k5ag22ke.wl%seb@cine7.net>

On Thu, 4 Dec 2008, at 01:42, Sébastien Cevey wrote:

> Introduce a git_get_file_or_project_config utility function to
> retrieve a repository variable either from a plain text file in the
> $GIT_DIR 

I would say that we try $GIT_DIR/$variable file.

> or else from 'gitweb.$variable' in the repository config 
> (e.g. 'description').

It _might_ also be added (just in case) that currently the only user
of this new subroutine is git_get_project_description, but this is
to change, and that is why this split was introduced.

> 
> Signed-off-by: Sebastien Cevey <seb@cine7.net>

But those are minor issues. So, FWIW

Acked-by: Jakub Narebski <jnareb@gmail.com>

> ---
>  gitweb/gitweb.perl |   24 ++++++++++++++++--------
>  1 files changed, 16 insertions(+), 8 deletions(-)
> 
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 933e137..b31274c 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -2001,18 +2001,26 @@ sub git_get_path_by_hash {
>  ## ......................................................................
>  ## git utility functions, directly accessing git repository
>  
> -sub git_get_project_description {
> -	my $path = shift;
> +# get the value of a config variable either from a file with the same
> +# name in the repository, or the gitweb.$name value in the repository
> +# config file.

It would probably be better to explicitly say that we use $git_dir/$name
file, or if it doesn't exist, gitweb.$name configuration variable.

> +sub git_get_file_or_project_config {
> +	my ($name, $path) = @_;

I think that $project, or $projectpath _might_ be better name for the
second argument to this subroutine.

>  
>  	$git_dir = "$projectroot/$path";
> -	open my $fd, "$git_dir/description"
> -		or return git_get_project_config('description');
> -	my $descr = <$fd>;
> +	open my $fd, "$git_dir/$name"
> +		or return git_get_project_config($name);
> +	my $conf = <$fd>;
>  	close $fd;
> -	if (defined $descr) {
> -		chomp $descr;
> +	if (defined $conf) {
> +		chomp $conf;
>  	}
> -	return $descr;
> +	return $conf;
> +}
> +
> +sub git_get_project_description {
> +	my $path = shift;
> +	return git_get_file_or_project_config('description', $path);
>  }

Nicely done.

>  
>  sub git_get_project_ctags {
> -- 
> 1.5.6.5
> 
> 

-- 
Jakub Narębski
Poland

  parent reply	other threads:[~2008-12-05  1:39 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-02 15:04 [PATCH] gitweb: Optional grouping of projects by category Sebastien Cevey
2008-12-02 23:36 ` Jakub Narebski
2008-12-03 14:22   ` [PATCH v2] " Sébastien Cevey
2008-12-03 22:51     ` Junio C Hamano
2008-12-03 23:12       ` Jakub Narebski
2008-12-04  0:39       ` [PATCH v3 0/3] " Sébastien Cevey
2008-12-04  0:43         ` Junio C Hamano
2008-12-04  0:42       ` [PATCH v3 1/3] gitweb: Modularized git_get_project_description to be more generic Sébastien Cevey
2008-12-04  0:44         ` [PATCH v3 2/3] gitweb: Split git_project_list_body in two functions Sébastien Cevey
2008-12-04  0:46           ` [PATCH v3 3/3] gitweb: Optional grouping of projects by category Sébastien Cevey
2008-12-04 19:37             ` Junio C Hamano
2008-12-05  2:08             ` Jakub Narebski
2008-12-05  2:32               ` Sébastien Cevey
2008-12-05 10:45                 ` Jakub Narebski
2008-12-11 23:34                   ` Sébastien Cevey
2008-12-12  0:13                     ` Jakub Narebski
2008-12-12  0:40                       ` Sébastien Cevey
2008-12-12  2:03                         ` Jakub Narebski
2008-12-12  3:10                           ` Sébastien Cevey
2008-12-12  9:26                             ` Jakub Narebski
2008-12-05  1:52           ` [PATCH v3 2/3] gitweb: Split git_project_list_body in two functions Jakub Narebski
2008-12-05  1:38         ` Jakub Narebski [this message]
2008-12-03 14:29   ` [PATCH] gitweb: Optional grouping of projects by category Sébastien Cevey
2008-12-03 21:14   ` Junio C Hamano

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

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

  git send-email \
    --in-reply-to=200812050238.16018.jnareb@gmail.com \
    --to=jnareb@gmail.com \
    --cc=barbieri@profusion.mobi \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pasky@suse.cz \
    --cc=seb@cine7.net \
    /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.
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).