private static void updateDirtyPathsForSubmodule(@NotNull GitSubmodule submodule,
                                                   boolean wasEmptyStaging,
                                                   @NotNull Map<VirtualFile, RootDirtySet> dirtyPaths,
                                                   @NotNull List<FilePath> newDirtyPaths) {
    GitRepository submoduleRepo = submodule.getRepository();
    GitRepository parentRepo = submodule.getParent();

    VirtualFile submoduleRoot = submoduleRepo.getRoot();
    VirtualFile parentRoot = parentRepo.getRoot();

    boolean isEmptyStaging = submoduleRepo.getStagingAreaHolder().isEmpty();
    if (isEmptyStaging == wasEmptyStaging) return;

    FilePath submoduleRootPath = VcsUtil.getFilePath(submoduleRoot);

    RootDirtySet parentDirtySet = dirtyPaths.get(parentRoot);
    if (parentDirtySet != null && parentDirtySet.belongsTo(submoduleRootPath)) return; // parent repo was refreshed

    // we store submodules as non-directory FilePath records
    FilePath submoduleRootPathAsFile = VcsUtil.getFilePath(submoduleRootPath.getPath(), false);
    GitFileStatus record = parentRepo.getStagingAreaHolder().findRecord(submoduleRootPathAsFile);
    if (record != null && record.getStagedStatus() != null) return; // no need to refresh if there are staged changes

    boolean parentThinksSubmoduleUnchanged = record == null;
    if (parentThinksSubmoduleUnchanged == isEmptyStaging) return; // parent repo agrees

    // refresh parent repo (and the submodule as a whole - which is costly)
    newDirtyPaths.add(submoduleRootPath);
  }
private static void updateDirtyPathsForSubmodule(@NotNull GitSubmodule submodule,
                                                   boolean wasEmptyStaging,
                                                   @NotNull Map<VirtualFile, RootDirtySet> dirtyPaths,
                                                   @NotNull List<FilePath> newDirtyPaths)