--- layout: default menu_item: api title: Pathspec description: Version 0.26.1 menu_item: api return_to: "API Documentation Index": /api/ sections: "create": "#create" "#matchDiff": "#matchDiff" "#matchIndex": "#matchIndex" "#matchTree": "#matchTree" "#matchWorkdir": "#matchWorkdir" "#matchesPath": "#matchesPath" "FLAG": "#FLAG" --- ## Pathspec.create Sync ```js var pathspec = Pathspec.create(pathspec); ``` | Parameters | Type | | | --- | --- | --- | | pathspec | [Strarray](/api/strarray/) | A git_strarray of the paths to match | | Returns | | | --- | --- | | [Pathspec](/api/pathspec/) | Output of the compiled pathspec | ## Pathspec#matchDiff Async ```js pathspec.matchDiff(diff, flags).then(function(pathspecMatchList) { // Use pathspecMatchList }); ``` | Parameters | Type | | --- | --- | --- | | diff | [Diff](/api/diff/) | A generated diff list | | flags | Number | Combination of git_pathspec_flag_t options to control match | | Returns | | | --- | --- | | [PathspecMatchList](/api/pathspec_match_list/) | Output list of matches; pass NULL to just get return value | ## Pathspec#matchIndex Async ```js pathspec.matchIndex(index, flags).then(function(pathspecMatchList) { // Use pathspecMatchList }); ``` | Parameters | Type | | --- | --- | --- | | index | [Index](/api/index/) | The index to match against | | flags | Number | Combination of git_pathspec_flag_t options to control match | | Returns | | | --- | --- | | [PathspecMatchList](/api/pathspec_match_list/) | Output list of matches; pass NULL to just get return value | ## Pathspec#matchTree Async ```js pathspec.matchTree(tree, flags).then(function(pathspecMatchList) { // Use pathspecMatchList }); ``` | Parameters | Type | | --- | --- | --- | | tree | [Tree](/api/tree/) | The root-level tree to match against | | flags | Number | Combination of git_pathspec_flag_t options to control match | | Returns | | | --- | --- | | [PathspecMatchList](/api/pathspec_match_list/) | Output list of matches; pass NULL to just get return value | ## Pathspec#matchWorkdir Async ```js pathspec.matchWorkdir(repo, flags).then(function(pathspecMatchList) { // Use pathspecMatchList }); ``` | Parameters | Type | | --- | --- | --- | | repo | [Repository](/api/repository/) | The repository in which to match; bare repo is an error | | flags | Number | Combination of git_pathspec_flag_t options to control match | | Returns | | | --- | --- | | [PathspecMatchList](/api/pathspec_match_list/) | Output list of matches; pass NULL to just get return value | ## Pathspec#matchesPath Sync ```js var result = pathspec.matchesPath(flags, path); ``` | Parameters | Type | | --- | --- | --- | | flags | Number | Combination of git_pathspec_flag_t options to control match | | path | String | The pathname to attempt to match | | Returns | | | --- | --- | | Number | 1 is path matches spec, 0 if it does not | ## Pathspec.FLAG ENUM | Flag | Value | | --- | --- | --- | | Pathspec.FLAG.DEFAULT | 0 | | Pathspec.FLAG.IGNORE_CASE | 1 | | Pathspec.FLAG.USE_CASE | 2 | | Pathspec.FLAG.NO_GLOB | 4 | | Pathspec.FLAG.NO_MATCH_ERROR | 8 | | Pathspec.FLAG.FIND_FAILURES | 16 | | Pathspec.FLAG.FAILURES_ONLY | 32 |