From 40dd662557969cbdece99608b8e0a187fdbe9ff6 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Mon, 8 Apr 2024 14:12:42 +0100 Subject: [PATCH] feat: accept `bazel-git fetch --negotation-tip` Currently does not use the tips. `go-git` by default retrieves the last 100 commits to send as "haves" to the server. This provides some level of pack file reduction until full negotiation is implemented. --- cmd/bazel-git/fetch.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cmd/bazel-git/fetch.go b/cmd/bazel-git/fetch.go index 7da1f02..16a731d 100644 --- a/cmd/bazel-git/fetch.go +++ b/cmd/bazel-git/fetch.go @@ -9,8 +9,9 @@ import ( ) type FetchCommand struct { - Depth int `long:"depth" value-name:"" description:"Limit fetching the specified number of commits from the tip of each remote branch history." require:"yes"` - NoWriteFetchHead bool `long:"no-write-fetch-head" description:"Does not write **FETCH_HEAD**." required:"yes"` + Depth int `long:"depth" value-name:"" description:"Limit fetching the specified number of commits from the tip of each remote branch history." require:"yes"` + NoWriteFetchHead bool `long:"no-write-fetch-head" description:"Does not write **FETCH_HEAD**." required:"yes"` + NegotiationTips []reference.Commitish `long:"negotiation-tip" value-name:"" description:"Determines the tips to use in negoatiating a smaller packfile transfer. Can be defined multiple times."` Args struct { Remote remote.URL `positional-arg-name:"repository" description:"The remote to retrieve objects from."` Commitishes []reference.Commitish `positional-arg-name:"refspec" description:"The committish to retrieve from the server. Usually a commit SHA but can be a resolvable reference."` @@ -20,8 +21,13 @@ type FetchCommand struct { var fetchCommand FetchCommand func (x *FetchCommand) Execute(_ []string) error { - log := slog.With("namespace", "fetch") + log := slog.With("namespace", "fetch", "remote", x.Args.Remote) log.Debug("fetching", "commitishes", x.Args.Commitishes) + + if len(x.NegotiationTips) > 0 { + log.Warn("Negotiation tips are not currently supported. A large packfile may be transferred", "negotiation-tips", x.NegotiationTips) + } + err := fetch.Commitishes(fetch.CommitishesOptions{ Remote: x.Args.Remote, Commitishes: x.Args.Commitishes, -- GitLab