How can I git-cvsimport multiple modules from a CVS repository, with differing branches?

流过昼夜 提交于 2019-12-03 16:00:00
VonC

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.

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)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!