2

tl;dr: Running git status --ignored in the root of my project never finishes. git status works fine.


I started seeing the symptoms of this issue from my IDE - PhpStorm (though this issue would apply to all IntelliJ IDEs). No git-related operations (commit, push, fetch) work, all of them would hang endlessly. Looking at the running processes, turns out there was a git process taking 100% CPU.

Killing the git processes made the IDE run smoothly again for a couple of minutes. Seems like it periodically spawns the process to sync up changes. Some experimenting later, turns out this is not an issue of PhpStorm, but of git. git status --ignored never finishes even when executed from the command line.

LazyOne
  • 137,403
  • 37
  • 338
  • 342
Martin Melka
  • 5,854
  • 10
  • 60
  • 114
  • Git does have some compiled-in path length limits. What OS was this on? If you can reproduce this on Linux, and send an example to the Git folks, they'll probably either fix the length limits for real, or at least fix Git not to get stuck. – torek Jan 27 '20 at 10:04
  • This was on OSX. I'll see if it reproduces in a linux docker container and on a baremetal Linux server. – Martin Melka Jan 27 '20 at 10:14
  • Confirmed that this fails on OSX, Linux-in-docker on OSX and on baremetal Linux (ubuntu) – Martin Melka Jan 27 '20 at 10:36

1 Answers1

2

In my case, the culprit was a deep directory structure in the project path. It must have been generated by something in our tool stack I didn't notice, because it was over 100 directories deep, with no actual files present there.

cp refused to copy this directory, saying name too long (not copied). I'm guessing git somehow trips up on directories like this.

Deleting the deeply nested dir hierarchy fixed the issue for me and git status --ignored works as expected now.


Edit: this was confirmed to be a bug in git. Exerpt from the mailing list:

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.

Martin Melka
  • 5,854
  • 10
  • 60
  • 114