From 7db545b14827462679760b2d584782d69695acf4 Mon Sep 17 00:00:00 2001 From: John Cai Date: Mon, 1 Nov 2021 18:11:08 -0400 Subject: Add ForceWithLease Push Option --force-with-lease allows a push to force push with some safety measures. If the ref on the remote is what we expect, then the force push is allowed to happen. See https://git-scm.com/docs/git-push#Documentation/git-push.txt---force-with-leaseltrefnamegt for more information --- options.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'options.go') diff --git a/options.go b/options.go index e54889f..fee2e16 100644 --- a/options.go +++ b/options.go @@ -228,10 +228,25 @@ type PushOptions struct { // FollowTags will send any annotated tags with a commit target reachable from // the refs already being pushed FollowTags bool + // ForceWithLease allows a force push as long as the remote ref adheres to a "lease" + ForceWithLease *ForceWithLease // PushOptions sets options to be transferred to the server during push. Options map[string]string } +// ForceWithLease sets fields on the lease +// If neither RefName nor Hash are set, ForceWithLease protects +// all refs in the refspec by ensuring the ref of the remote in the local repsitory +// matches the one in the ref advertisement. +type ForceWithLease struct { + // RefName, when set will protect the ref by ensuring it matches the + // hash in the ref advertisement. + RefName plumbing.ReferenceName + // Hash is the expected object id of RefName. The push will be rejected unless this + // matches the corresponding object id of RefName in the refs advertisement. + Hash plumbing.Hash +} + // Validate validates the fields and sets the default values. func (o *PushOptions) Validate() error { if o.RemoteName == "" { -- cgit From f92011d95f98f5deea4959c7d432704a4300d3a8 Mon Sep 17 00:00:00 2001 From: John Cai Date: Thu, 4 Nov 2021 15:02:00 -0400 Subject: simplified sparse checkout This is the initial logic to support a simple sparse checkout where directories to be included can be specified in CheckoutOptions. This change doesn't fully support the sparse patterns, nor does this change include the optimization to collapse flie entries in ithe index that are excluded via the sparse checkout directory patterns included under the parent directory. --- options.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'options.go') diff --git a/options.go b/options.go index e54889f..4b18ec1 100644 --- a/options.go +++ b/options.go @@ -291,6 +291,8 @@ type CheckoutOptions struct { // target branch. Force and Keep are mutually exclusive, should not be both // set to true. Keep bool + // SparseCheckoutDirectories + SparseCheckoutDirectories []string } // Validate validates the fields and sets the default values. -- cgit