Skip to content

Commit

Permalink
Clone only most recent commits
Browse files Browse the repository at this point in the history
This change should greatly reduce the bandwidth requirements of older
state repositories.
  • Loading branch information
Joshua Holland committed Jan 29, 2025
1 parent 373ab20 commit 4d615fe
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions storages/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,15 @@ func (storageSession *storageSession) clone(params *RequestMetadataParams) error
URL: params.Repository,
Auth: auth,
ReferenceName: ref(params.Ref, false),
// We only need to know the latest version of branches to be able to commit on top
// of them. And, we don't otherwise use the history of the repository. So, this
// saves a lot data.
// A further improvement that has not been implemented would be to use
// sparse-checkouts to only retrieve only blobs (i.e., files) from the server that
// we actually care about. The depth here prevents performance problems from
// history growth. sparse-checkouts help with horizontal growth (e.g., additional
// systems managed by the repository).
Depth: 1,
}

repository, err := git.Clone(storageSession.storer, storageSession.fs, cloneOptions)
Expand Down

0 comments on commit 4d615fe

Please sign in to comment.