|
|
|
|
|
|
|
|
import org.eclipse.jgit.errors.NoWorkTreeException; |
|
|
import org.eclipse.jgit.errors.NoWorkTreeException; |
|
|
import org.eclipse.jgit.lib.Constants; |
|
|
import org.eclipse.jgit.lib.Constants; |
|
|
import org.eclipse.jgit.lib.IndexDiff; |
|
|
import org.eclipse.jgit.lib.IndexDiff; |
|
|
|
|
|
import org.eclipse.jgit.lib.ProgressMonitor; |
|
|
import org.eclipse.jgit.lib.Repository; |
|
|
import org.eclipse.jgit.lib.Repository; |
|
|
import org.eclipse.jgit.treewalk.FileTreeIterator; |
|
|
import org.eclipse.jgit.treewalk.FileTreeIterator; |
|
|
import org.eclipse.jgit.treewalk.WorkingTreeIterator; |
|
|
import org.eclipse.jgit.treewalk.WorkingTreeIterator; |
|
|
|
|
|
|
|
|
public class StatusCommand extends GitCommand<Status> { |
|
|
public class StatusCommand extends GitCommand<Status> { |
|
|
private WorkingTreeIterator workingTreeIt; |
|
|
private WorkingTreeIterator workingTreeIt; |
|
|
private List<String> paths = null; |
|
|
private List<String> paths = null; |
|
|
|
|
|
private ProgressMonitor progressMonitor = null; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @param repo |
|
|
* @param repo |
|
|
|
|
|
|
|
|
IndexDiff diff = new IndexDiff(repo, Constants.HEAD, workingTreeIt); |
|
|
IndexDiff diff = new IndexDiff(repo, Constants.HEAD, workingTreeIt); |
|
|
if (paths != null) |
|
|
if (paths != null) |
|
|
diff.setFilter(PathFilterGroup.createFromStrings(paths)); |
|
|
diff.setFilter(PathFilterGroup.createFromStrings(paths)); |
|
|
diff.diff(); |
|
|
|
|
|
|
|
|
if (progressMonitor == null) |
|
|
|
|
|
diff.diff(); |
|
|
|
|
|
else |
|
|
|
|
|
diff.diff(progressMonitor, ProgressMonitor.UNKNOWN, |
|
|
|
|
|
ProgressMonitor.UNKNOWN, ""); //$NON-NLS-1$ |
|
|
return new Status(diff); |
|
|
return new Status(diff); |
|
|
} catch (IOException e) { |
|
|
} catch (IOException e) { |
|
|
throw new JGitInternalException(e.getMessage(), e); |
|
|
throw new JGitInternalException(e.getMessage(), e); |
|
|
|
|
|
|
|
|
this.workingTreeIt = workingTreeIt; |
|
|
this.workingTreeIt = workingTreeIt; |
|
|
return this; |
|
|
return this; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* To set the {@link ProgressMonitor} which contains callback methods to |
|
|
|
|
|
* inform you about the progress of this command. |
|
|
|
|
|
* |
|
|
|
|
|
* @param progressMonitor |
|
|
|
|
|
* @return {@code this} |
|
|
|
|
|
* @since 3.1 |
|
|
|
|
|
*/ |
|
|
|
|
|
public StatusCommand setProgressMonitor(ProgressMonitor progressMonitor) { |
|
|
|
|
|
this.progressMonitor = progressMonitor; |
|
|
|
|
|
return this; |
|
|
|
|
|
} |
|
|
} |
|
|
} |