diff options
author | Ben Talbot <ben@dropfake.com> | 2022-03-17 22:12:56 -0700 |
---|---|---|
committer | Ben Talbot <ben@dropfake.com> | 2024-04-19 22:13:15 -0700 |
commit | 0f3639790292f843a2577d97df1f0c3665e06501 (patch) | |
tree | 85978a0275373b74b4a74bd0849590aa08a2aa09 /options.go | |
parent | 302dddeda962e4bb3477a8e4080bc6f5a253e2bb (diff) | |
download | go-git-0f3639790292f843a2577d97df1f0c3665e06501.tar.gz |
git: worktree, add RestoreStaged which works like the "git restore --staged <file>..." command
Small formatting and style fixes before rebasing against master
Setup args for restore in TestExamples
Fix typo in error message and remove dependency on fmt in worktree_test
Diffstat (limited to 'options.go')
-rw-r--r-- | options.go | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -416,6 +416,9 @@ type ResetOptions struct { // the index (resetting it to the tree of Commit) and the working tree // depending on Mode. If empty MixedReset is used. Mode ResetMode + // Files, if not empty will constrain the reseting the index to only files + // specified in this list. + Files []string } // Validate validates the fields and sets the default values. @@ -790,3 +793,26 @@ type PlainInitOptions struct { // Validate validates the fields and sets the default values. func (o *PlainInitOptions) Validate() error { return nil } + +var ( + ErrNoRestorePaths = errors.New("you must specify path(s) to restore") +) + +// RestoreOptions describes how a restore should be performed. +type RestoreOptions struct { + // Marks to restore the content in the index + Staged bool + // Marks to restore the content of the working tree + Worktree bool + // List of file paths that will be restored + Files []string +} + +// Validate validates the fields and sets the default values. +func (o *RestoreOptions) Validate() error { + if len(o.Files) == 0 { + return ErrNoRestorePaths + } + + return nil +} |