I am using JGit libs to implement basic git operations.
Javadoc for ProgressMonitor
:
http://archive.eclipse.org/jgit/docs/jgit-2.0.0.201206130900-r/apidocs/org/eclipse/jgit/lib/ProgressMonitor.html
Here, you can see the log when I use a ProgressMonitor
for git clone
(implementation in the end):
- log start
- Total tasks: 2
- Task started: remote: Enumerating objects with total work: 0
- Task started: remote: Counting objects with total work: 56
- Task started: remote: Compressing objects with total work: 46
- Task started: Receiving objects with total work: 56
- Task ended: Receiving objects
- Task started: Resolving deltas with total work: 1
- Task ended: Resolving deltas
- Task started: Checking out files with total work: 23
- Task ended: Checking out files
- log ended
Now the question:
According to the method start
, there are 2 tasks, but the method beginTask
is reporting 6 tasks started and the method endTask
is reporting 3 tasks ended... Can anybody explain to me this magic?
The cloning process itself finished successfully.
Below you can see the implementation of ProgressMonitor
with methods writing to the log.
import org.eclipse.jgit.lib.ProgressMonitor;
public class MyProgressMonitor implements ProgressMonitor {
String currentTaskTitle;
@Override
public void start(int totalTasks) {
System.out.println("Total tasks: " + totalTasks);
}
@Override
public void beginTask(String title, int totalWork) {
currentTaskTitle = title;
System.out.println("Task started: " + title + " with total work: " + totalWork);
}
@Override
public void update(int completed) {
}
@Override
public void endTask() {
System.out.println("Task ended: " + currentTaskTitle);
}
@Override
public boolean isCancelled() {
return false;
}
}