From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sebastien Cevey Subject: [PATCH v4 1/3] gitweb: Modularized git_get_project_description to be more generic Date: Fri, 12 Dec 2008 00:41:20 +0100 Message-ID: <8763lqz3dr.wl%seb@cine7.net> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Cc: Junio C Hamano , Petr Baudis , Gustavo Sverzut Barbieri , seb@cine7.net To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Fri Dec 12 00:41:38 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 1LAv9y-0005Iq-HY for gcvg-git-2@gmane.org; Fri, 12 Dec 2008 00:41:35 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756219AbYLKXkR (ORCPT ); Thu, 11 Dec 2008 18:40:17 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756132AbYLKXkQ (ORCPT ); Thu, 11 Dec 2008 18:40:16 -0500 Received: from smtp.nimag.net ([62.220.136.11]:43361 "EHLO smtp.nimag.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753889AbYLKXkP (ORCPT ); Thu, 11 Dec 2008 18:40:15 -0500 Received: from crookshanks.cine7.net (85-218-42-96.dclient.lsne.ch [85.218.42.96]) by smtp.nimag.net (Postfix) with ESMTP id 13382CB0AA3; Fri, 12 Dec 2008 00:40:09 +0100 (CET) User-Agent: Wanderlust/2.14.0 (Africa) 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 --- Sorry, screwed up the previous email trying to keep that From line in the header.. This patch (1/3) is still identical to previous version (v3). gitweb/gitweb.perl | 24 ++++++++++++++++-------- 1 files changed, 16 insertions(+), 8 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 6eb370d..f7dc337 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -2020,18 +2020,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