Skip to content

Commit d407c82

Browse files
committed
libgit2: Add early return to transferProgressCallback
In transferProgressCallback(), if the received objects is equal to the total objects, return early with OK. Signed-off-by: Sunny <[email protected]>
1 parent afa82bb commit d407c82

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/git/libgit2/transport.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ func RemoteCallbacks(ctx context.Context, opts *git.AuthOptions) git2go.RemoteCa
5959
// libgit2 it should stop the transfer when the given context is closed (due to
6060
// e.g. a timeout).
6161
func transferProgressCallback(ctx context.Context) git2go.TransferProgressCallback {
62-
return func(_ git2go.TransferProgress) git2go.ErrorCode {
62+
return func(p git2go.TransferProgress) git2go.ErrorCode {
63+
// Early return if all the objects have been received.
64+
if p.ReceivedObjects == p.TotalObjects {
65+
return git2go.ErrorCodeOK
66+
}
6367
select {
6468
case <-ctx.Done():
6569
return git2go.ErrorCodeUser

0 commit comments

Comments
 (0)