无法将所有perforce分支导入git repo

Gra*_*erg 7 git perforce git-p4

我正在尝试将项目从我公司的Perforce仓库导入到git存储库中.我已成功将单个分支转换为单个git仓库,但我想要做的是将整个项目加上所有分支,但我无法使其正常工作.

我有我的.p4settings文件:

P4PORT=perforce-server.local:1666
P4USER=my.username
P4CLIENT=my.clientspec.name
Run Code Online (Sandbox Code Playgroud)

Clientspec非常简单:

//project/... //my.clientspec.name/project/...
-//project/External/... //my.clientspec.name/project/External/...
Run Code Online (Sandbox Code Playgroud)

第二行是从结帐中排除外部库二进制文件.

我使用以下命令行启动git-p4导入:

git p4 clone --verbose --detect-branches --max-changes=100 //project/...@all
Run Code Online (Sandbox Code Playgroud)

这将检查所有分支名称等,并尝试从第一次提交开始导入(此特定项目从changelist 771开始)

Importing from //project/...@all into project
Initialized empty Git repository in /Users/grant/Development/git_test/project/.git/
Reading pipe: git config git-p4.useclientspec
Reading pipe: git config git-p4.user
Reading pipe: git config git-p4.password
Reading pipe: git config git-p4.port
Reading pipe: git config git-p4.host
Reading pipe: git config git-p4.client
p4 -G branches
Opening pipe: p4 -G branches
p4 -G branch -o branch-1
Opening pipe: p4 -G branch -o branch-1
Reading pipe: git config --bool core.ignorecase
p4 -G branch -o branch-2
...
Opening pipe: p4 -G branch -o branch-n
p4-git branches: []
initial parents: {}
Run Code Online (Sandbox Code Playgroud)

我不确定p4-git分支和初始父母是否应该在这里是空的,但它们是.

最后,我们开始将变更列表导入git,以下情况发生:

Getting p4 changes for //project/...
p4 changes //project/...
Reading pipe: p4 changes //project/...
p4 -G describe 771
Opening pipe: p4 -G describe 771
Importing revision 771 (1%)branch is MAIN

    Importing new branch RCMerge/MAIN
p4 changes //RCMerge/MAIN/...@1,770
Reading pipe: p4 changes //RCMerge/MAIN/...@1,770

    Resuming with change 771
parent determined through known branches: Branch-foo
looking for initial parent for refs/remotes/p4/project/MAIN; current parent is refs/remotes/p4/project/Branch-foo
commit into refs/remotes/p4/project/MAIN
parent refs/remotes/p4/project/Branch-foo
p4 -G -x - print
Opening pipe: p4 -G -x - print
Glue/source/.empty
fatal: Invalid ref name or SHA1 expression: refs/remotes/p4/project/Branch-foo
fast-import: dumping crash report to .git/fast_import_crash_26002
Run Code Online (Sandbox Code Playgroud)

这是上面引用的文件:

fast-import crash report:
    fast-import process: 26002
    parent process     : 26000
    at Thu May 19 11:51:54 2011

fatal: Invalid ref name or SHA1 expression: refs/remotes/p4/project/Branch-foo

Most Recent Commands Before Crash
---------------------------------
  checkpoint
  commit refs/remotes/p4/project/MAIN
  committer Some User <some.user@domain.com> 1253574589 -0800
  data <<EOT
* from refs/remotes/p4/project/Branch-foo

Active Branch LRU
-----------------
    active_branches = 0 cur, 5 max

  pos  clock name
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Inactive Branches
-----------------
refs/remotes/p4/project/MAIN:
  status      : dirty
  tip commit  : 0000000000000000000000000000000000000000
  old tree    : 0000000000000000000000000000000000000000
  cur tree    : 0000000000000000000000000000000000000000
  commit clock: 0
  last pack   : 


Marks
-----

-------------------
END OF CRASH REPORT
Run Code Online (Sandbox Code Playgroud)

现在,作为一名新手,我不知道这意味着什么,也不知道如何解决这个问题,或者它是否可能.有没有人遇到过类似的问题?如果是这样,你是如何解决的?

Gra*_*erg 4

我终于找到了解决这个问题的方法。事实证明,Perforce 分支映射是反向完成的,这就是这个问题的根源。

Branch-foo 是从 MAIN 分支出来的,它应该有一个如下所示的分支映射:

//project/MAIN/... //project/Branch-foo/...
Run Code Online (Sandbox Code Playgroud)

然而,创建分支的人颠倒了映射,从而导致:

//project/Branch-foo/... //project/MAIN/...
Run Code Online (Sandbox Code Playgroud)

这混淆了 git-p4 作为 MAIN 的第一个变更列表从 #771 开始,而 Branch-foo 的变更列表从 #7652 开始,因此它在 Branch-foo 中找不到任何父级并崩溃了。将分支规范更改为上面列出的第一个可以解决问题。