diff options
author | Jeremy Stribling <strib@alum.mit.edu> | 2017-09-10 20:59:31 -0700 |
---|---|---|
committer | Jeremy Stribling <strib@alum.mit.edu> | 2017-09-11 08:56:54 -0700 |
commit | 52c1f982ea0004de419d1a7f69d7eaf8b8d6b659 (patch) | |
tree | 582a03b677b2a4c34c46c83f6511ad141c7b3ccb /remote.go | |
parent | bb3217ce5d5ed682a5c830c40ea031d3c92a8a7e (diff) | |
download | go-git-52c1f982ea0004de419d1a7f69d7eaf8b8d6b659.tar.gz |
config: support a configurable, and turn-off-able, pack.window
One use of go-git is to transfer git data from a non-standard git repo
(not stored in a file system, for example) to a "remote" backed by a
standard, local .git repo.
In this scenario, delta compression is not needed to reduce transfer
time over the "network", because there is no network. The underlying
storage layer has already taken care of the data tranfer, and sending
the objects to local .git storage doesn't require compression. So this
PR gives the user the option to turn off compression when it isn't
needed.
Of course, this results in a larger, uncompressed local .git repo, but
the user can then run git gc or git repack on that repo if they care
about the storage costs.
Turning the pack window to 0 on reduces total push time of a 36K repo
by 50 seconds (out of a pre-PR total of 3m26s).
Diffstat (limited to 'remote.go')
-rw-r--r-- | remote.go | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -797,17 +797,21 @@ func referencesToHashes(refs storer.ReferenceStorer) ([]plumbing.Hash, error) { func pushHashes( ctx context.Context, sess transport.ReceivePackSession, - sto storer.EncodedObjectStorer, + s storage.Storer, req *packp.ReferenceUpdateRequest, hs []plumbing.Hash, ) (*packp.ReportStatus, error) { rd, wr := io.Pipe() req.Packfile = rd + config, err := s.Config() + if err != nil { + return nil, err + } done := make(chan error) go func() { - e := packfile.NewEncoder(wr, sto, false) - if _, err := e.Encode(hs); err != nil { + e := packfile.NewEncoder(wr, s, false) + if _, err := e.Encode(hs, config.Pack.Window); err != nil { done <- wr.CloseWithError(err) return } |