@@ -287,9 +287,32 @@ func GitStatusFromFiles(ctx context.Context, loc string) (res *Status, err error
287287 }, nil
288288}
289289
290+ // StatusOption configures the behavior of git status
291+ type StatusOption func (* statusOptions )
292+
293+ type statusOptions struct {
294+ disableOptionalLocks bool
295+ }
296+
297+ // WithDisableOptionalLocks disables optional locks during git status
298+ func WithDisableOptionalLocks (disable bool ) StatusOption {
299+ return func (o * statusOptions ) {
300+ o .disableOptionalLocks = disable
301+ }
302+ }
303+
290304// Status runs git status
291- func (c * Client ) Status (ctx context.Context ) (res * Status , err error ) {
292- gitout , err := c .GitWithOutput (ctx , nil , "status" , "--porcelain=v2" , "--branch" , "-uall" )
305+ func (c * Client ) Status (ctx context.Context , opts ... StatusOption ) (res * Status , err error ) {
306+ options := & statusOptions {}
307+ for _ , opt := range opts {
308+ opt (options )
309+ }
310+
311+ args := []string {"status" , "--porcelain=v2" , "--branch" , "-uall" }
312+ if options .disableOptionalLocks {
313+ args = append ([]string {"--no-optional-locks" }, args ... )
314+ }
315+ gitout , err := c .GitWithOutput (ctx , nil , args [0 ], args [1 :]... )
293316 if err != nil {
294317 return nil , err
295318 }
0 commit comments