From: Sebastien Cevey Subject: [PATCHv3 1/3 (resend)] gitweb: Modularized git_get_project_description to be more generic Date: Thu, 4 Dec 2008 00:24:12 +0100 Message-ID: <87zlgxp595.wl%seb@cine7.net> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Cc: Jakub Narebski , Junio C Hamano To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Sun Feb 08 11:57:11 2009 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 1LW7LZ-00062Y-8P for gcvg-git-2@gmane.org; Sun, 08 Feb 2009 11:57:09 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753189AbZBHKzo (ORCPT ); Sun, 8 Feb 2009 05:55:44 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752395AbZBHKzn (ORCPT ); Sun, 8 Feb 2009 05:55:43 -0500 Received: from smtp.nimag.net ([62.220.136.11]:51997 "EHLO smtp.nimag.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752491AbZBHKzm (ORCPT ); Sun, 8 Feb 2009 05:55:42 -0500 Received: from crookshanks.cine7.net (unknown [164.15.3.77]) by smtp.nimag.net (Postfix) with ESMTP id 97922CB0B3D; Sun, 8 Feb 2009 11:55:38 +0100 (CET) User-Agent: SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL/10.7 Emacs/22.2 (x86_64-pc-linux-gnu) MULE/5.0 (SAKAKI) 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 --- Sending this patch again. It has been rebased onto 621f1b so it should apply cleanly on the current git master branch. gitweb/gitweb.perl | 24 ++++++++++++++++-------- 1 files changed, 16 insertions(+), 8 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index f27dbb6..e2550d5 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -2024,18 +2024,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