From 4d615fee65a425ea86f488f6a9f7011b9b35201b Mon Sep 17 00:00:00 2001 From: Joshua Holland Date: Wed, 29 Jan 2025 01:41:45 +0000 Subject: [PATCH] Clone only most recent commits This change should greatly reduce the bandwidth requirements of older state repositories. --- storages/git/git.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/storages/git/git.go b/storages/git/git.go index efe5579..3b0b9eb 100644 --- a/storages/git/git.go +++ b/storages/git/git.go @@ -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)