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