【问题标题】:Migrate svn to git with space in branch name将 svn 迁移到 git,分支名称中有空格
【发布时间】:2018-11-17 10:48:59
【问题描述】:

我想迁移到 svn 的 repo git 有问题。 在这个 repo 中,创建了一些名称为空格的分支。当我启动命令 git svn clone 我有一个错误

fatal: Not a valid object name refs/remotes/origin/My branch
cat-file commit refs/remotes/origin/My branch: command returned error: 128

我使用 svndumpfilter exclude 转储我的 repo,但问题是一样的。 我试图克隆使用忽略路径选项,但相同!

git svn clone --trunk=/Projet/trunk --branches=/Projet/branches --tags=/Projet/tags --authors-file=authors.txt file:///home/repo_svn/nom ../temp --ignore-path=".*(?:refs/remotes/origin/My branch|refs/remotes/origin/My%20branch)"

你有解决办法吗? 最好的问候

【问题讨论】:

标签: git svn clone space


【解决方案1】:

这对您来说可能为时已晚,但万一其他人点击此页面,我们也遇到了这个问题。崩溃的原因确实是由于分支名称中的空格 - 具体来说,git-svn.perl 中的cmt_metadata() sub 使用未转义的分支名称调用cat-file。我想将这种方法调整为更健壮不会太难。

但是。

虽然这是导致崩溃的原因,但事实证明,即使遇到这段代码也表明我们还有其他问题。具体来说,由于 git 配置中有多个 branches 条目,一些规则的右侧是冲突的。我们有类似的东西

branches=/branches/a*:/refs/remotes/origin/*
branches=/branches/b*:/refs/remotes/origin/*

认为是在initclone 命令行中使用--branches=/branches/a* --branches=/branches/b* 时获得的默认配置。事实证明,这些规则的右侧非常喜欢与左侧一样可区分。所以从头开始使用git svn init,然后编辑.git/config,添加:

branches=/branches/a*:/refs/remotes/origin/a/*
branches=/branches/b*:/refs/remotes/origin/b/*

并启动git svn fetch 似乎已修复它。分支仍然有空格,但不再碰到不喜欢它们的代码。

【讨论】:

  • 谢谢!这也为我解决了这个问题。我只想补充一点,只要它是唯一的,右侧就不需要与左侧匹配:branches=/branches/tom*:/refs/remotes/origin/a/* branches=/branches/dick*:/refs /remotes/origin/b/* 分支=/branches/harry*:/refs/remotes/origin/c/*
【解决方案2】:

在我的 Mac 上,我编辑了:

/Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git-svn

去了这个子并添加了对quotemeta的调用,似乎已经为我解决了这个问题,ymmv。

sub cmt_metadata {
  return extract_metadata((grep(/^git-svn-id: /,
  command(qw/cat-file commit/, quotemeta(shift))))[-1]);
}

然后 git svn clone 工作正常。

【讨论】:

    猜你喜欢
    • 2016-02-02
    • 1970-01-01
    • 2020-01-19
    • 2016-08-18
    • 2021-09-24
    • 2016-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多