From: Junio C Hamano <gitster@pobox.com>
To: Pavel Roskin <proski@gnu.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Calculate $commitsha1 in update() only when needed
Date: Sat, 08 Dec 2007 00:17:56 -0800 [thread overview]
Message-ID: <7vtzmtwqff.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: 20071208050745.29462.74137.stgit@dv.roinet.com
Pavel Roskin <proski@gnu.org> writes:
> diff --git a/git-cvsserver.perl b/git-cvsserver.perl
> index ecded3b..409b301 100755
> --- a/git-cvsserver.perl
> +++ b/git-cvsserver.perl
> @@ -2427,9 +2427,6 @@ sub update
> # first lets get the commit list
> $ENV{GIT_DIR} = $self->{git_path};
>
> - my $commitsha1 = `git rev-parse $self->{module}`;
> - chomp $commitsha1;
> -
> my $commitinfo = `git cat-file commit $self->{module} 2>&1`;
> unless ( $commitinfo =~ /tree\s+[a-zA-Z0-9]{40}/ )
> {
Hmm. The first rev-parse could be squelched with 2>/dev/null and then
you can check if it does not match [a-f0-9]{40} and die early before
running "cat-file commit", can't you?
Also the regexp to check "tree" object name above seems quite wrong ;-)
If the purpose of this check is to make sure if the ref points at a
commit object, perhaps...
my $commitsha1 = `git rev-parse --verify $self->{module}^0 2>&1`;
chomp($commitsha1);
if ($commitsha1 !~ /^[0-9a-f]{40}$/) {
die "no such module $self->{module}";
}
Then the other hunk below would become unnecessary, I think.
> @@ -2440,8 +2437,13 @@ sub update
> my $git_log;
> my $lastcommit = $self->_get_prop("last_commit");
>
> - if (defined $lastcommit && $lastcommit eq $commitsha1) { # up-to-date
> - return 1;
> + if (defined $lastcommit) {
> + my $commitsha1 = `git rev-parse $self->{module}`;
> + chomp $commitsha1;
> +
> + if ($lastcommit eq $commitsha1) { # up-to-date
> + return 1;
> + }
> }
>
> # Start exclusive lock here...
next prev parent reply other threads:[~2007-12-08 8:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-08 5:07 [PATCH] Calculate $commitsha1 in update() only when needed Pavel Roskin
2007-12-08 8:17 ` Junio C Hamano [this message]
2007-12-08 8:48 ` Pavel Roskin
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=7vtzmtwqff.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=proski@gnu.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.