git status --ignored 无限期挂起

git status --ignored hangs indefinitely

tl;dr: 我项目根目录中的 运行 git status --ignored 永远不会完成。 git status 工作正常。


我开始从我的 IDE - PhpStorm 中看到这个问题的症状(尽管这个问题适用于所有 IntelliJ IDE)。没有 git 相关的操作(提交、推送、获取)工作,所有这些都会无休止地挂起。查看 运行ning 进程,发现有一个 git 进程占用了 100% CPU。

终止 git 进程使 IDE 运行 再次顺利进行了几分钟。似乎它会定期生成同步更改的过程。后来进行了一些试验,结果证明这不是 PhpStorm 的问题,而是 git 的问题。 git status --ignored 即使从命令行执行也永远不会完成。

就我而言,罪魁祸首是项目路径中的深层目录结构。它一定是由我们工具堆栈中的 某些东西 生成的,我没有注意到,因为它有超过 100 个目录,那里没有实际文件。

cp 拒绝复制此目录,说 name too long (not copied)。我猜 git 不知何故在这样的目录上绊倒了。

删除深层嵌套的目录层次结构解决了我的问题,git status --ignored 现在可以正常工作了。


编辑:这已被确认为 git 中的错误。邮件列表摘录:

There is no such directory depth limit, but the runtime of 'git status --ignored' grows quickly with the depth of the untracked directory. Running this shell loop produces the numbers below:

10: 0.01
11: 0.03
12: 0.05
13: 0.11
14: 0.23
15: 0.47
16: 0.97
17: 1.97
18: 3.88
19: 7.85
20: 16.29
21: 32.92
22: 76.24

Beautifully quadratic, isn't it? :)

Unless I messed up my numbers, with a depth of 120 directories it would take over 6*10^23 years to complete... so yeah, it does qualify as indefinitely.