aboutsummaryrefslogtreecommitdiffstats
path: root/options.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-04-11 04:41:16 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2017-04-11 04:41:16 +0200
commit116fed7ea746255805f5664d9b6fd7cdb1b52663 (patch)
treec2fa3a6520f4254550eaf17af83a54526864db3f /options.go
parentaa818a3f77e6ff06765cf8c246f8708df3d190a7 (diff)
downloadgo-git-116fed7ea746255805f5664d9b6fd7cdb1b52663.tar.gz
worktree, status implementation based on merkletrie and reset and checkout implementations
Diffstat (limited to 'options.go')
-rw-r--r--options.go52
1 files changed, 52 insertions, 0 deletions
diff --git a/options.go b/options.go
index 1047d7e..61c0388 100644
--- a/options.go
+++ b/options.go
@@ -177,3 +177,55 @@ type SubmoduleUpdateOptions struct {
// submodules (and so on). Until the SubmoduleRescursivity is reached.
RecurseSubmodules SubmoduleRescursivity
}
+
+// CheckoutOptions describes how a checkout operation should be performed.
+type CheckoutOptions struct {
+ // Branch to be checked out, if empty uses `master`
+ Branch plumbing.ReferenceName
+ Hash plumbing.Hash
+ // RemoteName is the name of the remote to be pushed to.
+ Force bool
+}
+
+// Validate validates the fields and sets the default values.
+func (o *CheckoutOptions) Validate() error {
+ if o.Branch == "" {
+ o.Branch = plumbing.Master
+ }
+
+ return nil
+}
+
+type ResetMode int
+
+const (
+ // HardReset resets the index and working tree. Any changes to tracked files
+ // in the working tree are discarded.
+ HardReset ResetMode = iota
+ // MixedReset Resets the index but not the working tree (i.e., the changed
+ // files are preserved but not marked for commit) and reports what has not
+ // been updated. This is the default action.
+ MixedReset
+)
+
+// ResetOptions describes how a reset operation should be performed.
+type ResetOptions struct {
+ // Commit, if commit is pressent set the current branch head (HEAD) to it.
+ Commit plumbing.Hash
+ // Mode
+ Mode ResetMode
+}
+
+// Validate validates the fields and sets the default values.
+func (o *ResetOptions) Validate(r *Repository) error {
+ if o.Commit == plumbing.ZeroHash {
+ ref, err := r.Head()
+ if err != nil {
+ return err
+ }
+
+ o.Commit = ref.Hash()
+ }
+
+ return nil
+}