/** * Retrieve file status from an already calculated IndexDiff * * @param path * @param indexDiff * @return file status */ private static Status getFileStatus(String path, IndexDiff indexDiff) { if (indexDiff.getAssumeUnchanged().contains(path)) { return Status.ASSUME_UNCHANGED; } else if (indexDiff.getAdded().contains(path)) { // added if (indexDiff.getModified().contains(path)) return Status.ADDED_INDEX_DIFF; else return Status.ADDED; } else if (indexDiff.getChanged().contains(path)) { // changed if (indexDiff.getModified().contains(path)) return Status.MODIFIED_INDEX_DIFF; else return Status.MODIFIED; } else if (indexDiff.getUntracked().contains(path)) { // untracked if (indexDiff.getRemoved().contains(path)) return Status.REMOVED_UNTRACKED; else return Status.UNTRACKED; } else if (indexDiff.getRemoved().contains(path)) { // removed return Status.REMOVED; } else if (indexDiff.getMissing().contains(path)) { // missing return Status.REMOVED_NOT_STAGED; } else if (indexDiff.getModified().contains(path)) { // modified (and not changed!) return Status.MODIFIED_NOT_STAGED; } return Status.UNKNOWN; }
private void buildIndexHeadDiffList(IProject[] selectedProjects, IProgressMonitor monitor) throws IOException, OperationCanceledException { monitor.beginTask(UIText.CommitActionHandler_calculatingChanges, 1000); EclipseGitProgressTransformer jgitMonitor = new EclipseGitProgressTransformer(monitor); CountingVisitor counter = new CountingVisitor(); for (IProject p : selectedProjects) { try { p.accept(counter); } catch (CoreException e) { // ignore } } WorkingTreeIterator it = IteratorService.createInitialIterator(repo); if (it == null) throw new OperationCanceledException(); // workspace is closed indexDiff = new IndexDiff(repo, Constants.HEAD, it); indexDiff.diff( jgitMonitor, counter.count, 0, NLS.bind(UIText.CommitActionHandler_repository, repo.getDirectory().getPath())); includeList(indexDiff.getAdded(), indexChanges); includeList(indexDiff.getChanged(), indexChanges); includeList(indexDiff.getRemoved(), indexChanges); includeList(indexDiff.getMissing(), notIndexed); includeList(indexDiff.getModified(), notIndexed); includeList(indexDiff.getUntracked(), notTracked); if (monitor.isCanceled()) throw new OperationCanceledException(); monitor.done(); }
private static Set<String> getCommitableChanges( Repository repo, IServer server, IProgressMonitor monitor) throws IOException { EclipseGitProgressTransformer jgitMonitor = new EclipseGitProgressTransformer(monitor); IndexDiff indexDiff = new IndexDiff(repo, Constants.HEAD, IteratorService.createInitialIterator(repo)); indexDiff.diff(jgitMonitor, 0, 0, NLS.bind("Repository: {0}", repo.getDirectory().getPath())); Set<String> set = new HashSet<String>(); if (commitAddedResources(server)) set.addAll(indexDiff.getAdded()); if (commitChangedResources(server)) set.addAll(indexDiff.getChanged()); if (commitConflictingResources(server)) set.addAll(indexDiff.getConflicting()); if (commitMissingResources(server)) set.addAll(indexDiff.getMissing()); if (commitModifiedResources(server)) set.addAll(indexDiff.getModified()); if (commitRemovedResources(server)) set.addAll(indexDiff.getRemoved()); if (commitUntrackedResources(server)) set.addAll(indexDiff.getUntracked()); return set; }
StatusResult(File projectPath, IndexDiff indexDiff) { this.projectPath = projectPath; ignoredMap.put(projectPath.toString(), Boolean.FALSE); if (indexDiff == null) { return; } for (String relativePathString : indexDiff.getIgnoredNotInIndex()) { String absolutePathString = new File(projectPath, relativePathString).toString(); ignoredMap.put(absolutePathString, Boolean.TRUE); } addToStatusSetMap(indexDiff.getAdded(), WorkNodeStatus.ADDED); addToStatusSetMap(indexDiff.getChanged(), WorkNodeStatus.CHANGED); addToStatusSetMap(indexDiff.getConflicting(), WorkNodeStatus.CONFLICTING); addToStatusSetMap(indexDiff.getMissing(), WorkNodeStatus.MISSING); addToStatusSetMap(indexDiff.getModified(), WorkNodeStatus.MODIFIED); addToStatusSetMap(indexDiff.getRemoved(), WorkNodeStatus.REMOVED); addToStatusSetMap(indexDiff.getUntracked(), WorkNodeStatus.UNTRACKED); }