1

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;
    }
}
Rüdiger Herrmann
  • 20,512
  • 11
  • 62
  • 79
psova
  • 192
  • 2
  • 11
  • Seems like a bug, at least in the progress book-keeping of the `CloneCommand`. Did you try other commands that accept a progress monitor? I suggest to file a bug report here: https://www.eclipse.org/jgit/support/ – Rüdiger Herrmann Nov 01 '20 at 16:37
  • 1
    Reported as https://bugs.eclipse.org/bugs/show_bug.cgi?id=568425 Also, I have tested git fetch and there are also some discrepancies: Total tasks: 2, started 5 and ended 2 – psova Nov 01 '20 at 22:50

0 Answers0