From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?ISO-8859-1?Q?S=E9bastien?= Cevey Subject: [PATCH v3 1/3] gitweb: Modularized git_get_project_description to be more generic Date: Thu, 04 Dec 2008 01:42:41 +0100 Message-ID: <87k5ag22ke.wl%seb@cine7.net> References: <87wsei1uvp.wl%seb@cine7.net> <200812030036.13562.jnareb@gmail.com> <87prk91got.wl%seb@cine7.net> <7viqq0c1pg.fsf@gitster.siamese.dyndns.org> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Cc: Jakub Narebski , Junio C Hamano , Petr Baudis , Gustavo Sverzut Barbieri To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Thu Dec 04 01:42:58 2008 Return-path: Envelope-to: gcvg-git-2@gmane.org Received: from vger.kernel.org ([209.132.176.167]) by lo.gmane.org with esmtp (Exim 4.50) id 1L82Iy-0005ik-7U for gcvg-git-2@gmane.org; Thu, 04 Dec 2008 01:42:56 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752417AbYLDAlj (ORCPT ); Wed, 3 Dec 2008 19:41:39 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752117AbYLDAlj (ORCPT ); Wed, 3 Dec 2008 19:41:39 -0500 Received: from smtp.nimag.net ([62.220.136.11]:35823 "EHLO smtp.nimag.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751886AbYLDAli (ORCPT ); Wed, 3 Dec 2008 19:41:38 -0500 Received: from crookshanks.cine7.net (85-218-46-136.dclient.lsne.ch [85.218.46.136]) by smtp.nimag.net (Postfix) with ESMTP id 2362FCB0A89; Thu, 4 Dec 2008 01:41:37 +0100 (CET) In-Reply-To: <7viqq0c1pg.fsf@gitster.siamese.dyndns.org> User-Agent: Wanderlust/2.14.0 (Africa) X-Message-Flag: OUTLOOK ERROR: Large chicken feathers stuck in power supply fan. Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: 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 or else from 'gitweb.$variable' in the repository config (e.g. 'description'). Signed-off-by: Sebastien Cevey --- 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. +sub git_get_file_or_project_config { + my ($name, $path) = @_; $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); } sub git_get_project_ctags { -- 1.5.6.5