@@ -178,6 +178,72 @@ type SubmoduleUpdateOptions struct {
178
178
RecurseSubmodules SubmoduleRescursivity
179
179
}
180
180
181
+ // CheckoutOptions describes how a checkout 31operation should be performed.
182
+ type CheckoutOptions struct {
183
+ // Hash to be checked out, if used HEAD will in detached mode. Branch and
184
+ // Hash are mutual exclusive.
185
+ Hash plumbing.Hash
186
+ // Branch to be checked out, if Branch and Hash are empty is set to `master`.
187
+ Branch plumbing.ReferenceName
188
+ // Force, if true when switching branches, proceed even if the index or the
189
+ // working tree differs from HEAD. This is used to throw away local changes
190
+ Force bool
191
+ }
192
+
193
+ // Validate validates the fields and sets the default values.
194
+ func (o * CheckoutOptions ) Validate () error {
195
+ if o .Branch == "" {
196
+ o .Branch = plumbing .Master
197
+ }
198
+
199
+ return nil
200
+ }
201
+
202
+ // ResetMode defines the mode of a reset operation.
203
+ type ResetMode int8
204
+
205
+ const (
206
+ // HardReset resets the index and working tree. Any changes to tracked files
207
+ // in the working tree are discarded.
208
+ HardReset ResetMode = iota
209
+ // MixedReset resets the index but not the working tree (i.e., the changed
210
+ // files are preserved but not marked for commit) and reports what has not
211
+ // been updated. This is the default action.
212
+ MixedReset
213
+ // MergeReset resets the index and updates the files in the working tree
214
+ // that are different between Commit and HEAD, but keeps those which are
215
+ // different between the index and working tree (i.e. which have changes
216
+ // which have not been added).
217
+ //
218
+ // If a file that is different between Commit and the index has unstaged
219
+ // changes, reset is aborted.
220
+ MergeReset
221
+ )
222
+
223
+ // ResetOptions describes how a reset operation should be performed.
224
+ type ResetOptions struct {
225
+ // Commit, if commit is pressent set the current branch head (HEAD) to it.
226
+ Commit plumbing.Hash
227
+ // Mode, form resets the current branch head to Commit and possibly updates
228
+ // the index (resetting it to the tree of Commit) and the working tree
229
+ // depending on Mode. If empty MixedReset is used.
230
+ Mode ResetMode
231
+ }
232
+
233
+ // Validate validates the fields and sets the default values.
234
+ func (o * ResetOptions ) Validate (r * Repository ) error {
235
+ if o .Commit == plumbing .ZeroHash {
236
+ ref , err := r .Head ()
237
+ if err != nil {
238
+ return err
239
+ }
240
+
241
+ o .Commit = ref .Hash ()
242
+ }
243
+
244
+ return nil
245
+ }
246
+
181
247
// LogOptions describes how a log action should be performed.
182
248
type LogOptions struct {
183
249
// When the From option is set the log will only contain commits
0 commit comments