Bug 568425 - ProgressMonitor for Git clone task is reporting wrong number of totalTask from method start
Summary: ProgressMonitor for Git clone task is reporting wrong number of totalTask fro...
Status: NEW
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: 5.9   Edit
Hardware: All Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-01 17:49 EST by Peter Sova CLA
Modified: 2020-11-01 18:19 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Sova CLA 2020-11-01 17:49:06 EST
Used implementation for ProgressMonitor to test the monitoring:

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;
    }
}

Git clone log:

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

In short, 2 tasks reported as total from method 'start', while 6 reported from method 'beginTask' and 3 from method 'endTask'
Comment 1 Peter Sova CLA 2020-11-01 18:01:50 EST
Tested the same implementation of ProgressMonitor for git fetch.
Here is the log:

Total tasks: 2
Task started: remote: Enumerating objects with total work: 0
Task started: remote: Counting objects with total work: 5
Task started: remote: Compressing objects with total work: 2
Task started: Receiving objects with total work: 3
Task ended: Receiving objects
Task started: Updating references with total work: 1
Task ended: Updating references

In short, 2 tasks reported as total from method 'start', while 4 reported from method 'beginTask' and 2 from method 'endTask'
Comment 2 Peter Sova CLA 2020-11-01 18:02:25 EST
Tested the same implementation of ProgressMonitor for git fetch.
Here is the log:

Total tasks: 2
Task started: remote: Enumerating objects with total work: 0
Task started: remote: Counting objects with total work: 5
Task started: remote: Compressing objects with total work: 2
Task started: Receiving objects with total work: 3
Task ended: Receiving objects
Task started: Updating references with total work: 1
Task ended: Updating references

In short, 2 tasks reported as total from method 'start', while 4 reported from method 'beginTask' and 2 from method 'endTask'
Comment 3 Thomas Wolf CLA 2020-11-01 18:19:39 EST
Yes, that's known. Which doesn't mean it shouldn't be fixed, of course. :-) 

Compare EGit's EclipseGitProgressTransformer, which bridges the JGit ProgressMonitor to Eclipse's IProgressMonitor, and see the Gerrit comments at [1].

[1] https://git.eclipse.org/r/c/egit/egit/+/88434/2/org.eclipse.egit.core/src/org/eclipse/egit/core/EclipseGitProgressTransformer.java#24