【发布时间】:2011-02-08 10:29:06
【问题描述】:
看起来 git-p4 不是 Windows 的 MSys-Git 项目的一部分。有人知道如何让它通过 Windows 运行吗?
【问题讨论】:
-
你说得对,Windows 版 Git(也称为 MSysGit)不支持它。功能请求github.com/msysgit/msysgit/issues/108
标签: windows git perforce version-control
看起来 git-p4 不是 Windows 的 MSys-Git 项目的一部分。有人知道如何让它通过 Windows 运行吗?
【问题讨论】:
标签: windows git perforce version-control
2019 年 7 月更新,Gabriel Morin 现在提到了“Git P4 clone broken”问题:
[alias]
p4 = !python.exe 'c:\\program files\\Git\\mingw64\\libexec\\git-core\\git-p4'
然后在命令行中使用
git p4就可以了。
借助 Git 2.32(2021 年第二季度),git p4 学会了更有效地查找分支点。
参见Joachim Kuebart (jkuebart) 的commit 6b79818、commit c3ab088(2021 年 5 月 5 日)。
(由 Junio C Hamano -- gitster -- 合并到 commit e289f68,2021 年 5 月 14 日)
git-p4: 加快查找分支父节点签字人:Joachim Kuebart
协助人:Junio C Hamano
协助人:Luke Diamand
对于
git-p4导入的每个新分支,它需要找到从其父分支分支的提交。
虽然p4没有明确记录此信息,但分支上的第一个更改列表通常是父分支的相同副本。方法
searchParent()尝试在给定“父”分支的历史记录中找到一个提交,其树与新分支的初始更改列表“target”完全匹配。
代码遍历父提交,并使用diff-tree将它们中的每一个与此初始更改列表进行比较。由于我们已经知道要查找的树对象名称,因此为每次提交生成
diff-tree是一种浪费。使用“
rev-list”的“--format”选项查找历史中每个commit的树对象名称,找到与目标commit的树名称完全相同的树进行优化这个。这会带来相当大的加速,至少在 Windows 上是这样。
在一台 Windows 机器上,在父分支中有大约 16000 次提交的相当大的存储库,当前代码需要 7 多分钟,而对于相同的更改列表,新代码只需要 10 多秒:之前:
$ time git p4 sync Importing from/into multiple branches Depot paths: //depot Importing revision 31274 (100.0%) Updated branches: b1 real 7m41.458s user 0m0.000s sys 0m0.077s之后:
$ time git p4 sync Importing from/into multiple branches Depot paths: //depot Importing revision 31274 (100.0%) Updated branches: b1 real 0m10.235s user 0m0.000s sys 0m0.062s
2020 年 3 月更新
在 Git 2.27(2020 年第二季度)中,“git p4”已更新为与 Python 3 一起使用。
见commit 6bb40ed(2020 年 1 月 23 日)SZEDER Gábor (szeder)。
见commit 7575f4f,commit ce425eb,commit 2e2aa8d,commit a6b1306,commit 4294d74,commit 50da1e7,commit 5a5577d,commit d38208a,commit 86dca24,@9876543440@,@9876543440@,@9876543441(commit 1f8b46d,@987654 2019 年 12 月)Yang Zhao (yangminz).
请参阅 Ben Keene (seraphire) 的 commit 484d09c(2019 年 12 月 13 日)。
(由 Junio C Hamano -- gitster -- 合并于 commit 9a0fa17,2020 年 3 月 25 日)
ci: 在 linux-gcc 和 osx-gcc 和 python2 其他地方使用 python3签字人:SZEDER Gábor
Python2 已结束生命周期,我们一直在准备 Python 脚本以与 Python3 一起使用。
'
git p4',Python 的主要 in-tree 用户,刚刚收到了一些兼容性更新。
这仅在 Git 2.30(2021 年第一季度)中记录在 commit 263dc0。
2018 年 7 月更新:
Git 2.19(2018 年第三季度)将开始为 git p4 带来 Python 3 支持。
参见commit db2d997、commit f2606b1、commit efdcc99、commit 4d88519、commit dba1c9d、commit fc35c9d(2018 年 6 月 19 日)Luke Diamand (luked99)。
(由Junio C Hamano -- gitster -- 合并commit 6dcd364,2018 年 7 月 18 日)
编写代码以使“git p4”更接近 Python 3 的可用性。
2016 年 1 月更新:
自 2010 年起,contrib/fast-import/git-p4.README 自 2012 年 4 月起提及
git-p4 脚本移至 git 源目录的顶层。 请注意,顶级 git-p4.py 脚本现在是源代码
Windows 用户可以直接复制
git-p4.py源脚本,可能 通过同一文件夹中名为“git-p4.bat”的批处理文件调用它。
它应该只包含一行:
@python "%~d0%~p0git-p4.py" %*
(虽然这是2013 article is invoking git-p4.py directly)
原始答案(2010 年 4 月)
正如“Why Perforce is more scalable than Git”中提到的,注意不要在 Git any p4 repo 中导入。 Git 无法处理 P4 可以管理的那种巨大的独特 repo。
Git-P4 在 Python 中,它应该在 Windows 上运行(就像在 this question 中一样)
您可以grab git-p4.py here 并将其用作 git-p4.bat
@python "%~d0%~p0git-p4" %*
它需要安装 Python 2.x。
别忘了还有another approach as well。
【讨论】:
我得到了它的工作,但这是一个漫长而艰巨的过程,充满了危险。我在我的博客上写了说明:http://ericlathrop.com/2012/12/how-to-set-up-git-p4-in-windows/
【讨论】:
我找到的最简单的答案是Timo Geusch's blog:
C:\Python27 中(libexec\git-core,例如在我的 Git for Windows 1.9.4-preview20140611 上安装在 Windows 7 64 位上,即 C:\Program Files (x86)\Git\libexec\git-core
在同一位置,编辑“git-p4”无扩展名文件,用单行替换虚拟 echo 和 exit 行
c:/python27/python "c:/program files (x86)/Git/libexec/git-core/git-p4.py" $1 $2 $3 $4 $5 $6 $7 $8 $9
就是这样。 git-p4 现在可以在您的 MSysGit / Git for Windows 安装上运行,就像在任何 linux 机器上一样。
(请注意,Eric Lathrop's existing answer 有很多关于使用 git-p4 及其所有限制的附加信息;我认为这个问题可以从一个简单的如何回答实际问题中受益,即很容易让它工作Windows,免得让更多的流浪者像我上周一样灰心)
【讨论】:
python 2to3.py -w git-p4.py(假设 2to3.py 和 git-p4.py 都在当前目录中)。
看完https://git-scm.com/docs/git-p4
py -2 "C:\Program Files\Git\mingw64\libexec\git-core\git-p4" clone //Projects/App/@all
为我工作
【讨论】: