( ctx context.Context, sess transport.ReceivePackSession, s storage.Storer, req *packp.ReferenceUpdateRequest, hs []plumbing.Hash, useRefDeltas bool, allDelete bool, )
| 1425 | } |
| 1426 | |
| 1427 | func pushHashes( |
| 1428 | ctx context.Context, |
| 1429 | sess transport.ReceivePackSession, |
| 1430 | s storage.Storer, |
| 1431 | req *packp.ReferenceUpdateRequest, |
| 1432 | hs []plumbing.Hash, |
| 1433 | useRefDeltas bool, |
| 1434 | allDelete bool, |
| 1435 | ) (*packp.ReportStatus, error) { |
| 1436 | rd, wr := io.Pipe() |
| 1437 | |
| 1438 | config, err := s.Config() |
| 1439 | if err != nil { |
| 1440 | return nil, err |
| 1441 | } |
| 1442 | |
| 1443 | // Set buffer size to 1 so the error message can be written when |
| 1444 | // ReceivePack fails. Otherwise the goroutine will be blocked writing |
| 1445 | // to the channel. |
| 1446 | done := make(chan error, 1) |
| 1447 | |
| 1448 | if !allDelete { |
| 1449 | req.Packfile = rd |
| 1450 | go func() { |
| 1451 | e := packfile.NewEncoder(wr, s, useRefDeltas) |
| 1452 | if _, err := e.Encode(hs, config.Pack.Window); err != nil { |
| 1453 | done <- wr.CloseWithError(err) |
| 1454 | return |
| 1455 | } |
| 1456 | |
| 1457 | done <- wr.Close() |
| 1458 | }() |
| 1459 | } else { |
| 1460 | close(done) |
| 1461 | } |
| 1462 | |
| 1463 | rs, err := sess.ReceivePack(ctx, req) |
| 1464 | if err != nil { |
| 1465 | // close the pipe to unlock encode write |
| 1466 | _ = rd.Close() |
| 1467 | return nil, err |
| 1468 | } |
| 1469 | |
| 1470 | if err := <-done; err != nil { |
| 1471 | return nil, err |
| 1472 | } |
| 1473 | |
| 1474 | return rs, nil |
| 1475 | } |
| 1476 | |
| 1477 | func (r *Remote) updateShallow(o *FetchOptions, resp *packp.UploadPackResponse) error { |
| 1478 | if o.Depth == 0 || len(resp.Shallows) == 0 { |
no test coverage detected