File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 66 "path/filepath"
77 "regexp"
88 "sort"
9+ "strings"
910
1011 "github.com/git-lfs/gitobj/errors"
1112)
4041func NewSet (db string ) (* Set , error ) {
4142 pd := filepath .Join (db , "pack" )
4243
43- paths , err := filepath .Glob (filepath .Join (pd , "*.pack" ))
44+ paths , err := filepath .Glob (filepath .Join (escapeGlobPattern ( pd ) , "*.pack" ))
4445 if err != nil {
4546 return nil , err
4647 }
@@ -91,6 +92,21 @@ func NewSet(db string) (*Set, error) {
9192 return NewSetPacks (packs ... ), nil
9293}
9394
95+ // globEscapes uses these escapes because filepath.Glob does not understand
96+ // backslash escapes on Windows.
97+ var globEscapes = map [string ]string {
98+ "*" : "[*]" ,
99+ "?" : "[?]" ,
100+ "[" : "[[]" ,
101+ }
102+
103+ func escapeGlobPattern (s string ) string {
104+ for char , escape := range globEscapes {
105+ s = strings .Replace (s , char , escape , - 1 )
106+ }
107+ return s
108+ }
109+
94110// NewSetPacks creates a new *Set from the given packfiles.
95111func NewSetPacks (packs ... * Packfile ) * Set {
96112 m := make (map [byte ][]* Packfile )
You can’t perform that action at this time.
0 commit comments