代码之家  ›  专栏  ›  技术社区  ›  Danny

Git SVN拒绝在SVN存储库上创建分支错误:“不在同一存储库中”

  •  4
  • Danny  · 技术社区  · 17 年前

    我正在尝试创建一个 svn branch using git-svn . 存储库是用创建的 --stdlayout .不幸的是,它会生成一个错误,说明“源和目标似乎不在同一个存储库中”。错误似乎是由于源URL中不包含用户名造成的。

    $git svn branch foo as bar-m“尝试将foo变为bar。”

    复制svn+ssh://my.foo.company/r/sandbox/foo/trunk at R1173到 svn+ssh://svnuser@my.foo.company/r/sandbox/foo/branches/foo as bar…

    尝试使用不支持的功能:源和目标似乎不支持 在同一个存储库中(源代码: ’ svn+ssh://my.foo.company公司 /r/sandbox/foo/trunk'; DST: ’ svn+ssh://svnuser@my.foo.company /r/sandbox/foo/branches/foo as bar') at/home/me/.install/git/libexec/git core/git svn line 610

    我最初认为这只是一个配置问题,检查 .git/config 没有任何不正确的建议。

     [svn-remote "svn"]
         url = svn+ssh://svnuser@my.foo.company/r
         fetch = sandbox/foo/trunk:refs/remotes/trunk
         branches = sandbox/foo/branches/*:refs/remotes/*
         tags = sandbox/foo/tags/*:refs/remotes/tags/*
    

    我正在使用 git version 1.6.3.3 .

    有人能解释一下为什么会发生这种情况,以及如何最好地解决它吗?

    2 回复  |  直到 16 年前
        1
  •  1
  •   gotgenes    16 年前

    此修补程序中的实际修复程序,从 the mailing list thread :

    diff --git a/git-svn.perl b/git-svn.perl
    index dba0d12..650c9e5 100755
    --- a/git-svn.perl
    +++ b/git-svn.perl
    @@ -663,7 +663,8 @@ sub cmd_branch {
            }
            $head ||= 'HEAD';
    
    -   my ($src, $rev, undef, $gs) = working_head_info($head);
    +   my (undef, $rev, undef, $gs) = working_head_info($head);
    +   my $src = $gs->full_url;
    
            my $remote = Git::SVN::read_all_remotes()->{$gs->{repo_id}};
            my $allglobs = $remote->{ $_tag ? 'tags' : 'branches' };
    

    注意,对于丹尼使用的同一版本,1.6.3.3,我在588找到了这一特定行。在Ubuntu Karmic 9.10中,这个脚本是 /usr/lib/git-core/git-svn .

        2
  •  4
  •   slacker    17 年前

    我认为这是git svn中的一个bug,如果您观察到错误中的源存储库,它将丢失URL中的svnuser@部分。这是因为git svn使用来自commit message的svn repo?我不确定。我修改了git svn perl脚本,在第609行中包含了硬编码的URL,从而使其工作正常。在你的例子中,609行看起来像这样……

    $src=“svn+ssh://svnuser@my.foo.company/r/sandbox/foo/trunk”;

    注意,如果您的Git SVN比我的更新/旧,则可能会有所不同。在我成功分支之后,我移除了这条线(因为我只需要分支两次)。我要提交一份错误报告。

    还要注意,如果您使用的是非SVN+ssh类型的repo。例如file:///home/r/sandbox/foo/trunk这不是问题。