From: Lea Wiemann <lewiemann@gmail.com>
To: git@vger.kernel.org
Cc: Lea Wiemann <LeWiemann@gmail.com>
Subject: [PATCH v2] gitweb: use Git.pm, and use its parse_rev method for git_get_head_hash
Date: Sat, 31 May 2008 16:19:24 +0200 [thread overview]
Message-ID: <1212243564-30109-1-git-send-email-LeWiemann@gmail.com> (raw)
In-Reply-To: <20080531130450.GI18781@machine.or.cz>
This simplifies git_get_head_hash a lot; the method might eventually
even go away.
I haven't checked whether this causes an IO performance regression by
instantiating a new Git repository instance, but in the end
Git->repository will be as fast as possible and do no eager disk
accesses. No benchmarking yet at this stage.
Signed-off-by: Lea Wiemann <LeWiemann@gmail.com>
---
Per your request without the cleanup. I won't submit the cleanup
patch separately, but I assume it will get cleaned up eventually when
someone touches that function.
gitweb/gitweb.perl | 20 ++++++--------------
1 files changed, 6 insertions(+), 14 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 57a1905..0ed3d6e 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -16,6 +16,7 @@ use Encode;
use Fcntl ':mode';
use File::Find qw();
use File::Basename qw(basename);
+use Git;
binmode STDOUT, ':utf8';
BEGIN {
@@ -1508,20 +1509,11 @@ sub git_cmd_str {
# get HEAD ref of given project as hash
sub git_get_head_hash {
my $project = shift;
- my $o_git_dir = $git_dir;
- my $retval = undef;
- $git_dir = "$projectroot/$project";
- if (open my $fd, "-|", git_cmd(), "rev-parse", "--verify", "HEAD") {
- my $head = <$fd>;
- close $fd;
- if (defined $head && $head =~ /^([0-9a-fA-F]{40})$/) {
- $retval = $1;
- }
- }
- if (defined $o_git_dir) {
- $git_dir = $o_git_dir;
- }
- return $retval;
+ my $directory = "$projectroot/$project";
+ # Legacy side effect on $git_dir. This will eventually go
+ # away as the global $git_dir is eliminated.
+ $git_dir = $directory if (!defined $git_dir);
+ Git->repository(Directory => $directory)->parse_rev("HEAD");
}
# get type of given object
--
1.5.5.GIT
next prev parent reply other threads:[~2008-05-31 14:20 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-30 23:00 [PATCH] gitweb: use Git.pm, and use its parse_rev method for git_get_head_hash Lea Wiemann
2008-05-30 23:03 ` Lea Wiemann
2008-05-31 9:40 ` Jakub Narebski
2008-05-31 12:39 ` Lea Wiemann
2008-06-01 22:19 ` Jakub Narebski
2008-06-02 5:35 ` Junio C Hamano
2008-06-02 9:29 ` Petr Baudis
2008-06-02 21:32 ` Jakub Narebski
2008-06-02 22:31 ` Lea Wiemann
2008-05-31 13:04 ` Petr Baudis
2008-05-31 14:19 ` Lea Wiemann [this message]
2008-05-31 14:34 ` [PATCH v2] " Lea Wiemann
2008-06-01 8:23 ` Junio C Hamano
2008-06-01 15:44 ` Lea Wiemann
2008-06-01 21:33 ` Junio C Hamano
2008-06-01 22:16 ` [PATCH] test-lib.sh: set PERL5LIB instead of GITPERLLIB Lea Wiemann
2008-06-02 5:17 ` Junio C Hamano
2008-06-02 14:08 ` Lea Wiemann
2008-06-02 14:13 ` [PATCH v2] " Lea Wiemann
2008-06-02 20:01 ` Junio C Hamano
2008-06-02 22:19 ` Lea Wiemann
2008-06-03 0:20 ` [PATCH] " Lea Wiemann
2008-06-01 23:18 ` [PATCH v2] gitweb: use Git.pm, and use its parse_rev method for git_get_head_hash Lea Wiemann
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1212243564-30109-1-git-send-email-LeWiemann@gmail.com \
--to=lewiemann@gmail.com \
--cc=git@vger.kernel.org \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).