spdr870/gitextensions — pull request #1049 by vcpp (2012-06-17 22:34:40+00:00)
Title: Infinite status updates for submodule in subdirectory

Steps:
1. Just create two empty repositories, i.e. “OuterRepo” and “InnerRepo”
2. Add the second repo as submodule with relative to outer repo path “some/deep/path”
3. Open the first repo in Git Extensions

current: GE infinitely calls git.exe to check status (1 call per second per submodule).
expected: GE does nothing until something changed.

It seems that the following check in ToolStripGitStatus.cs isn't enough to ignore all unwanted changes:

// new submodule changed
string modulePath = "\\modules\\";
int index = e.FullPath.IndexOf(modulePath, gitPath.Length);
if (index >= 0 && e.FullPath.IndexOf("\\", index + modulePath.Length) == -1)
return;

When submodule is in the root directory (“...modules\InnerRepo”), there are no slashes after “modules\” and change will be ignored (it's ok), but for submodules in subdirectories (“...modules\some\deep\path\InnerRepo” there are few additional slashes after “modules\” and before submodule's gitdir, so another check is scheduled (it's bug).

For repository with number of large submodules this issue totally slows down cpu and disk I/O.

My suggestion is to ignore all directory-related changes inside “.git\modules\” directory:

if (e.FullPath.StartsWith(submodulesPath) && (Directory.Exists(e.FullPath)))
return;

At least this change prevents an infinite loop. I'm not sure if ignoring all directory (not file) changes is correct for submodule's gitdir, but I couldn't find scenario with false ignore when something was changed, but status wasn't updated. If you'll find one, please, let me know.