commit. All merging is assumed to have taken place
independently of git-svn functions.
-'rebuild'::
- Not a part of daily usage, but this is a useful command if
- you've just cloned a repository (using gitlink:git-clone[1]) that was
- tracked with git-svn. Unfortunately, git-clone does not clone
- git-svn metadata and the svn working tree that git-svn uses for
- its operations. This rebuilds the metadata so git-svn can
- resume fetch operations. A Subversion URL may be optionally
- specified at the command-line if the directory/repository you're
- tracking has moved or changed protocols.
-
'show-ignore'::
Recursively finds and lists the svn:ignore property on
directories. The output is suitable for appending to
--no-metadata::
This gets rid of the git-svn-id: lines at the end of every commit.
- With this, you lose the ability to use the rebuild command. If
- you ever lose your .git/svn/git-svn/.rev_db file, you won't be
- able to fetch again, either. This is fine for one-shot imports.
+ If you lose your .git/svn/git-svn/.rev_db file, git-svn will not
+ be able to rebuild it and you won't be able to fetch again,
+ either. This is fine for one-shot imports.
The 'git-svn log' command will not work on repositories using this,
either.
--
-COMPATIBILITY OPTIONS
----------------------
---
-
---upgrade::
-Only used with the 'rebuild' command.
-
-Run this if you used an old version of git-svn that used
-"git-svn-HEAD" instead of "remotes/git-svn" as the branch
-for tracking the remote.
-
---ignore-nodate::
-Only used with the 'fetch' command.
-
-By default git-svn will crash if it tries to import a revision
-from SVN which has '(no date)' listed as the date of the revision.
-This is repository corruption on SVN's part, plain and simple.
-But sometimes you really need those revisions anyway.
-
-If supplied git-svn will convert '(no date)' entries to the UNIX
-epoch (midnight on Jan. 1, 1970). Yes, that's probably very wrong.
-SVN was very wrong.
-
---
-
Basic Examples
~~~~~~~~~~~~~~
{ 'stdin|' => \$_stdin, %cmt_opts, %fc_opts, } ],
'show-ignore' => [ \&cmd_show_ignore, "Show svn:ignore listings",
{ 'revision|r=i' => \$_revision } ],
- rebuild => [ \&cmd_rebuild, "Rebuild git-svn metadata (after git clone)",
- { 'copy-remote|remote=s' => \$_cp_remote,
- 'upgrade' => \$_upgrade } ],
'multi-init' => [ \&cmd_multi_init,
'Initialize multiple trees (like git-svnimport)',
{ %multi_opts, %init_opts, %remote_opts,
version() if $_version;
usage(1) unless defined $cmd;
load_authors() if $_authors;
-unless ($cmd =~ /^(?:init|rebuild|multi-init|commit-diff)$/) {
+unless ($cmd =~ /^(?:init|multi-init|commit-diff)$/) {
Git::SVN::Migration::migration_check();
}
eval {
exit 0;
}
-sub cmd_rebuild {
- my $url = shift;
- my $gs = $url ? Git::SVN->init($url)
- : eval { Git::SVN->new };
- $gs ||= Git::SVN->_new;
- if (!verify_ref($gs->refname.'^0')) {
- $gs->copy_remote_ref;
- }
-
- my ($rev_list, $ctx) = command_output_pipe("rev-list", $gs->refname);
- my $latest;
- my $svn_uuid;
- while (<$rev_list>) {
- chomp;
- my $c = $_;
- fatal "Non-SHA1: $c\n" unless $c =~ /^$sha1$/o;
- my ($url, $rev, $uuid) = cmt_metadata($c);
-
- # ignore merges (from set-tree)
- next if (!defined $rev || !$uuid);
-
- # if we merged or otherwise started elsewhere, this is
- # how we break out of it
- if ((defined $svn_uuid && ($uuid ne $svn_uuid)) ||
- ($gs->{url} && $url && ($url ne $gs->{url}))) {
- next;
- }
-
- unless (defined $latest) {
- if (!$gs->{url} && !$url) {
- fatal "SVN repository location required\n";
- }
- $gs = Git::SVN->init($url);
- $latest = $rev;
- }
- $gs->rev_db_set($rev, $c);
- print "r$rev = $c\n";
- }
- command_close_pipe($rev_list, $ctx);
-}
-
sub do_git_init_db {
unless (-d $ENV{GIT_DIR}) {
my @init_db = ('init');
$self->{url} = command_oneline('config', '--get',
"svn-remote.$repo_id.url") or
die "Failed to read \"svn-remote.$repo_id.url\" in config\n";
+ if (-z $self->{db_path} && ::verify_ref($self->refname.'^0')) {
+ $self->rebuild;
+ }
$self;
}
$url;
}
-sub copy_remote_ref {
- my ($self) = @_;
- my $origin = $::_cp_remote ? $::_cp_remote : 'origin';
- my $ref = $self->refname;
- if (command('ls-remote', $origin, $ref)) {
- command_noisy('fetch', $origin, "$ref:$ref");
- } elsif ($::_cp_remote && !$::_upgrade) {
- die "Unable to find remote reference: $ref on $origin\n";
- }
-}
-
sub traverse_ignore {
my ($self, $fh, $path, $r) = @_;
$path =~ s#^/+##g;
}
}
+sub rebuild {
+ my ($self) = @_;
+ print "Rebuilding $self->{db_path} ...\n";
+ my ($rev_list, $ctx) = command_output_pipe("rev-list", $self->refname);
+ my $latest;
+ my $full_url = $self->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);
+
+ # ignore merges (from set-tree)
+ next if (!defined $rev || !$uuid);
+
+ # if we merged or otherwise started elsewhere, this is
+ # how we break out of it
+ if ((defined $svn_uuid && ($uuid ne $svn_uuid)) ||
+ ($full_url && $url && ($url ne $full_url))) {
+ next;
+ }
+ $latest ||= $rev;
+ $svn_uuid ||= $uuid;
+
+ $self->rev_db_set($rev, $c);
+ print "r$rev = $c\n";
+ }
+ command_close_pipe($rev_list, $ctx);
+ print "Done rebuilding $self->{db_path}\n";
+}
+
# rev_db:
# Tie::File seems to be prone to offset errors if revisions get sparse,
# it's not that fast, either. Tie::File is also not in Perl 5.6. So