diff options
author | Jakob Unterwurzacher | 2020-08-15 16:08:16 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2020-08-15 16:08:16 +0200 |
commit | 15b0b4a5fd268b421ddc347e4417b2538a540922 (patch) | |
tree | 5969cdd448bb3c105f15fe90b6f768d4be52bd1c /internal/fusefrontend_reverse/excluder.go | |
parent | f270135c1614843f43a9df0e68b6e3fa556b6774 (diff) |
v2api/reverse: start wiring up -exclude functionality
Exclude in readdir is missing.
Diffstat (limited to 'internal/fusefrontend_reverse/excluder.go')
-rw-r--r-- | internal/fusefrontend_reverse/excluder.go | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/internal/fusefrontend_reverse/excluder.go b/internal/fusefrontend_reverse/excluder.go index 337c3d2..b6cb961 100644 --- a/internal/fusefrontend_reverse/excluder.go +++ b/internal/fusefrontend_reverse/excluder.go @@ -15,15 +15,19 @@ import ( // prepareExcluder creates an object to check if paths are excluded // based on the patterns specified in the command line. func prepareExcluder(args fusefrontend.Args) *ignore.GitIgnore { - if len(args.Exclude) > 0 || len(args.ExcludeWildcard) > 0 || len(args.ExcludeFrom) > 0 { - excluder, err := ignore.CompileIgnoreLines(getExclusionPatterns(args)...) - if err != nil { - tlog.Fatal.Printf("Error compiling exclusion rules: %q", err) - os.Exit(exitcodes.ExcludeError) - } - return excluder + if len(args.Exclude) == 0 && len(args.ExcludeWildcard) == 0 && len(args.ExcludeFrom) == 0 { + return nil + } + patterns := getExclusionPatterns(args) + if len(patterns) == 0 { + panic(patterns) + } + excluder, err := ignore.CompileIgnoreLines(patterns...) + if err != nil { + tlog.Fatal.Printf("Error compiling exclusion rules: %v", err) + os.Exit(exitcodes.ExcludeError) } - return nil + return excluder } // getExclusionPatters prepares a list of patterns to be excluded. |