diff options
author | Ian Lance Taylor <iant@golang.org> | 2010-11-10 13:25:49 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2010-11-10 13:25:49 -0800 |
commit | be0b649eb1efcf2c0f86e823c364322b7561ad5e (patch) | |
tree | 414020994e1b661e0f22b11fa18fbce1a610bec4 | |
parent | 194dde22c39bef4db8db580a1de7c67b6f67103f (diff) | |
download | go-git-be0b649eb1efcf2c0f86e823c364322b7561ad5e.tar.gz |
path: Fix Glob when it finds a file in directory position.
When searching a list of directories, the files which match
the pattern are accumulated in a slice. If the glob has a
wildcard for the directory, and the wildcard matches a file
rather than a directory, then the files found so far are
discarded. E.g., path.Glob("*/x") in a directory which
contains both files and subdirectories. This patch avoids
discarding matches found so far when a file is found.
R=r
CC=bsiegert, golang-dev
https://golang.org/cl/3015042
-rw-r--r-- | src/pkg/path/match.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/pkg/path/match.go b/src/pkg/path/match.go index d5cd19fd40..dd3422c425 100644 --- a/src/pkg/path/match.go +++ b/src/pkg/path/match.go @@ -240,9 +240,13 @@ func Glob(pattern string) (matches []string) { // glob searches for files matching pattern in the directory dir // and appends them to matches. func glob(dir, pattern string, matches []string) []string { - if fi, err := os.Stat(dir); err != nil || !fi.IsDirectory() { + fi, err := os.Stat(dir) + if err != nil { return nil } + if !fi.IsDirectory() { + return matches + } d, err := os.Open(dir, os.O_RDONLY, 0666) if err != nil { return nil |