public boolean visit()

in org.eclipse.egit.core/src/org/eclipse/egit/core/internal/indexdiff/GitResourceDeltaVisitor.java [96:204]


	public boolean visit(IResourceDelta delta) throws CoreException {
		final IResource resource = delta.getResource();
		if (resource.getType() == IResource.ROOT) {
			return true;
		}

		if (resource.getType() == IResource.PROJECT) {
			if (delta.getKind() == IResourceDelta.REMOVED) {
				IPath loc = deletedProjects.remove(resource);
				if (loc != null) {
					projectDeleted |= !loc.toFile().isDirectory();
				}
				return false;
			}
			// If the resource is not part of a project under
			// Git revision control or from a different repository
			if (!ResourceUtil.isSharedWithGit(resource)) {
				// Ignore the change for project and its children
				return false;
			}
			GitProjectData gitData = GitProjectData.get((IProject) resource);
			if (gitData == null) {
				return false;
			}
			RepositoryMapping mapping = gitData.getRepositoryMapping(resource);
			if (mapping == null || !gitData.hasInnerRepositories()
					&& mapping.getRepository() != repository) {
				return false;
			}
			// continue with children
			return true;
		}

		Repository repositoryOfResource = null;
		if (resource.isLinked()) {
			IPath location = resource.getLocation();
			if (location == null) {
				return false;
			}
			repositoryOfResource = ResourceUtil.getRepository(location);
			// Ignore linked files, folders and their children, if they're not
			// in the same repository
			if (repository != repositoryOfResource) {
				return false;
			}
		} else {
			repositoryOfResource = ResourceUtil.getRepository(resource);
		}

		if (resource.getType() == IResource.FOLDER) {
			GitProjectData gitData = GitProjectData.get(resource.getProject());
			if (gitData == null) {
				return false;
			}
			if (repositoryOfResource == null || !gitData.isProtected(resource)
					&& repositoryOfResource != repository) {
				return false;
			}
			if (delta.getKind() == IResourceDelta.ADDED) {
				IPath repoRelativePath = ResourceUtil.getRepositoryRelativePath(
						resource.getLocation(), repository);
				if (repoRelativePath == null) {
					return false;
				}
				if (!repoRelativePath.isEmpty()) {
					String path = repoRelativePath.toPortableString() + "/"; //$NON-NLS-1$
					if (isIgnoredInOldIndex(path)) {
						return true; // keep going to catch .gitignore files.
					}
					filesToUpdate.add(path);
					resourcesToUpdate.add(resource);
				}
			}

			// continue with children
			return true;
		}

		if (repositoryOfResource != repository) {
			return false;
		}

		if (!isInteresting(delta)) {
			return false;
		}

		if (resource.getName().equals(Constants.DOT_GIT_IGNORE)) {
			gitIgnoreChanged = true;
			return false;
		}

		IPath repoRelativePath = ResourceUtil
				.getRepositoryRelativePath(resource.getLocation(), repository);
		if (repoRelativePath == null) {
			resourcesToUpdate.add(resource);
			return true;
		}

		String path = repoRelativePath.toPortableString();
		if (isIgnoredInOldIndex(path)) {
			// This file is ignored in the old index, and ignore rules did not
			// change: ignore the delta to avoid unnecessary index updates
			return false;
		}

		filesToUpdate.add(path);
		resourcesToUpdate.add(resource);
		return true;
	}