git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: Sam Vilain <sam@vilain.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] git-svn: use git-log rather than rev-list | xargs cat-file
Date: Sun, 10 Jun 2007 14:24:59 -0700	[thread overview]
Message-ID: <20070610212459.GA12222@muzzle> (raw)
In-Reply-To: <20070610091259.48F8D13A4F8@magnus.utsl.gen.nz>

Sam Vilain <sam@vilain.net> wrote:
> This saves a bit of time when rebuilding the git-svn index.

Does git-log still have the 16k buffer limit?  If so then we can't use
it because commit messages over 16k will be truncated and the git-svn-id
line will not show up.  Also, if that limit is removed I'd prefer to
just add --pretty=raw to rev-list because git-log is stil porcelain and
more likely to change.

> Signed-off-by: Sam Vilain <sam@vilain.net>
> ---
>  git-svn.perl |   30 +++++++++++++++++++-----------
>  1 files changed, 19 insertions(+), 11 deletions(-)
> 
> diff --git a/git-svn.perl b/git-svn.perl
> index e350061..610563c 100755
> --- a/git-svn.perl
> +++ b/git-svn.perl
> @@ -802,10 +802,15 @@ sub cmt_metadata {
>  
>  sub working_head_info {
>  	my ($head, $refs) = @_;
> -	my ($fh, $ctx) = command_output_pipe('rev-list', $head);
> -	while (my $hash = <$fh>) {
> -		chomp($hash);
> -		my ($url, $rev, $uuid) = cmt_metadata($hash);
> +	my ($fh, $ctx) = command_output_pipe('log', $head);
> +	my $hash;
> +	while (<$fh>) {
> +		if ( m{^commit ($::sha1)$} ) {
> +			$hash = $1;
> +			next;
> +		}
> +		next unless s{^\s+(git-svn-id:)}{$1};
> +		my ($url, $rev, $uuid) = extract_metadata($_);
>  		if (defined $url && defined $rev) {
>  			if (my $gs = Git::SVN->find_by_url($url)) {
>  				my $c = $gs->rev_db_get($rev);
> @@ -1964,16 +1969,19 @@ sub rebuild {
>  		return;
>  	}
>  	print "Rebuilding $db_path ...\n";
> -	my ($rev_list, $ctx) = command_output_pipe("rev-list", $self->refname);
> +	my ($log, $ctx) = command_output_pipe("log", $self->refname);
>  	my $latest;
>  	my $full_url = $self->full_url;
>  	remove_username($full_url);
>  	my $svn_uuid;
> -	while (<$rev_list>) {
> -		chomp;
> -		my $c = $_;
> -		die "Non-SHA1: $c\n" unless $c =~ /^$::sha1$/o;
> -		my ($url, $rev, $uuid) = ::cmt_metadata($c);
> +	my $c;
> +	while (<$log>) {
> +		if ( m{^commit ($::sha1)$} ) {
> +			$c = $1;
> +			next;
> +		}
> +		next unless s{^\s*(git-svn-id:)}{$1};
> +		my ($url, $rev, $uuid) = ::extract_metadata($_);
>  		remove_username($url);
>  
>  		# ignore merges (from set-tree)
> @@ -1991,7 +1999,7 @@ sub rebuild {
>  		$self->rev_db_set($rev, $c);
>  		print "r$rev = $c\n";
>  	}
> -	command_close_pipe($rev_list, $ctx);
> +	command_close_pipe($log, $ctx);
>  	print "Done rebuilding $db_path\n";
>  }
>  
> -- 
> 1.5.0.4.210.gf8a7c-dirty
> 

-- 
Eric Wong

  reply	other threads:[~2007-06-10 21:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-10  9:00 [PATCH] git-svn: use git-log rather than rev-list | xargs cat-file Sam Vilain
2007-06-10 21:24 ` Eric Wong [this message]
2007-06-11  7:34   ` Junio C Hamano
2007-06-12  5:34     ` [PATCH] Extend --pretty=oneline to cover the first paragraph, so that an ugly commit message like this can be handled sanely Junio C Hamano
2007-06-12  6:17     ` [PATCH] git-svn: use git-log rather than rev-list | xargs cat-file Eric Wong
  -- strict thread matches above, loose matches on Subject: below --
2007-06-30  8:56 a bunch of outstanding updates Sam Vilain
2007-06-30  8:56 ` [PATCH] repack: improve documentation on -a option Sam Vilain
2007-06-30  8:56   ` [PATCH] git-svn: use git-log rather than rev-list | xargs cat-file Sam Vilain

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=20070610212459.GA12222@muzzle \
    --to=normalperson@yhbt.net \
    --cc=git@vger.kernel.org \
    --cc=sam@vilain.net \
    /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 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 NNTP newsgroup(s).