diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2020-06-14 01:42:12 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2020-06-14 01:42:12 +0200 |
commit | ae693a97b7f10b672dfd5816a0dc2bb3cb3bfa9f (patch) | |
tree | 11a3bc96f3e1a6520c652f832aa1b66a2222779a /options.go | |
parent | b77bbc985343c5b866136c89fc2c3919002c1acf (diff) | |
download | go-git-ae693a97b7f10b672dfd5816a0dc2bb3cb3bfa9f.tar.gz |
Worktree.AddWithOptions: improve documentation and interface
Diffstat (limited to 'options.go')
-rw-r--r-- | options.go | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -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. |