简体   繁体   English

我如何从具有不同分支的CVS存储库中git-cvsimport多个模块?

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

I'm trying to git-cvsimport several different modules from CVS, all of which are on different branches. 我正在尝试从CVS中git-cvsimport几个不同的模块,所有这些模块都在不同的分支上。

So far I've done this (in pseudo-bash code): 到目前为止,我已经完成了这个(在伪bash代码中):

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 . 但是这为每个模块创建了一个不同的git存储库 How would I merge them all into one, if that's even remotely possible? 如果可能的话,我怎么把它们合并成一个呢?

What I've done is modified the git-cvsimport perl script, I've changed the update_index() method from: 我所做的是修改了git-cvsimport perl脚本,我已经改变了update_index()方法:

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.) (注意添加了$cvs_tree变量。)

Works like a charm. 奇迹般有效。 To execute: 执行:

perl git-cvsimport -v ... (rest of regular git-cvsimport arguments)

In theory, you could use git grafts to merge your repositories into one: 理论上,您可以使用git grafts将您的存储库合并为一个:
See "Is there a clean way to handle two original git repositories that started with the same content?" 请参阅“有没有一种干净的方法来处理以相同内容开头的两个原始git存储库?”

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. 在实践中,您可能希望查看另一个工具,如cvs2git ,并检查它是否不以更一致的方式导入分支。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM