5

I'm trying to git-cvsimport several different modules from CVS, all of which are on different branches.

So far I've done this (in pseudo-bash code):

for each ($MODULE, $BRANCH); do
    git-cvsimport -p x -v -d "$CVS_REPO" "$MODULE" -o "$BRANCH" -C "$MODULE"
done

But that makes a different git repository for each module. How would I merge them all into one, if that's even remotely possible?

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
Neil
  • 24,551
  • 15
  • 60
  • 81

2 Answers2

2

What I've done is modified the git-cvsimport perl script, I've changed the update_index() method from:

sub update_index (\@\@) {
    my $old = shift;
    my $new = shift;
    open(my $fh, '|-', qw(git update-index -z --index-info))
        or die "unable to open git update-index: $!";
    print $fh
        (map { "0 0000000000000000000000000000000000000000\t$_\0" }
            @$old),
        (map { '100' . sprintf('%o', $_->[0]) . " $_->[1]\t$_->[2]\0" }
            @$new)
        or die "unable to write to git update-index: $!";
    close $fh
        or die "unable to write to git update-index: $!";
    $? and die "git update-index reported error: $?";
}

To:

sub update_index (\@\@) {
    my $old = shift;
    my $new = shift;
    open(my $fh, '|-', qw(git update-index -z --index-info))
        or die "unable to open git update-index: $!";
    print $fh
        (map { "0 0000000000000000000000000000000000000000\t$cvs_tree/$_\0" }
            @$old),
        (map { '100' . sprintf('%o', $_->[0]) . " $_->[1]\t$cvs_tree/$_->[2]\0" }
            @$new)
        or die "unable to write to git update-index: $!";
    close $fh
        or die "unable to write to git update-index: $!";
    $? and die "git update-index reported error: $?";
}

(Notice the addition of the $cvs_tree variable.)

Works like a charm. To execute:

perl git-cvsimport -v ... (rest of regular git-cvsimport arguments)
Steven Devijver
  • 2,553
  • 1
  • 22
  • 22
  • just tried with 1.7.5 on centos 5.5 and it failed. tried perl /usr/local/libexec/git-core/git-cvsimport -v -d /root/cvs_mirror/java -C testdir -r cvs -k – Olivier Refalo Apr 27 '11 at 23:29
  • forget it, I got it: one needs to add the full path to the repo as the module name - it wasn't clear from your description: the correct command line is git cvsimport -v -d /path/to/repo -C testdir -r cvs -k /path/to/repo – Olivier Refalo Apr 27 '11 at 23:31
1

In theory, you could use git grafts to merge your repositories into one:
See "Is there a clean way to handle two original git repositories that started with the same content?"

In practice, you might want to look at another tool like cvs2git, and check if it does not import branches in a more consistent way.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • It says you need direct access to the repository to use cvs2git. If you just have remote access, it's a hack, apparently. – Neil Jul 30 '09 at 13:58