aboutsummaryrefslogtreecommitdiffstats
path: root/options.go
diff options
context:
space:
mode:
Diffstat (limited to 'options.go')
-rw-r--r--options.go21
1 files changed, 20 insertions, 1 deletions
diff --git a/options.go b/options.go
index d222267..8495e97 100644
--- a/options.go
+++ b/options.go
@@ -2,6 +2,7 @@ package git
import (
"errors"
+ "fmt"
"regexp"
"strings"
"time"
@@ -375,8 +376,26 @@ var (
// AddOptions describes how a add operation should be performed
type AddOptions struct {
- All bool
+ // All equivalent to `git add -A`, update the index not only where the
+ // working tree has a file matching `Path` but also where the index already
+ // has an entry. This adds, modifies, and removes index entries to match the
+ // working tree. If no `Path` nor `Glob` is given when `All` option is
+ // used, all files in the entire working tree are updated.
+ All bool
+ // Path is the exact filepath to a the file or directory to be added.
Path string
+ // Glob adds all paths, matching pattern, to the index. If pattern matches a
+ // directory path, all directory contents are added to the index recursively.
+ Glob string
+}
+
+// Validate validates the fields and sets the default values.
+func (o *AddOptions) Validate(r *Repository) error {
+ if o.Path != "" && o.Glob != "" {
+ return fmt.Errorf("fields Path and Glob are mutual exclusive")
+ }
+
+ return nil
}
// CommitOptions describes how a commit operation should be performed.