2 * Copyright (C) the libgit2 contributors. All rights reserved.
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
7 #ifndef INCLUDE_pathspec_h__
8 #define INCLUDE_pathspec_h__
12 #include "git2/pathspec.h"
18 /* public compiled pathspec */
27 PATHSPEC_DATATYPE_STRINGS
= 0,
28 PATHSPEC_DATATYPE_DIFF
= 1,
31 typedef git_array_t(char *) git_pathspec_string_array_t
;
33 /* public interface to pathspec matching */
34 struct git_pathspec_match_list
{
35 git_pathspec
*pathspec
;
36 git_array_t(void *) matches
;
37 git_pathspec_string_array_t failures
;
42 /* what is the common non-wildcard prefix for all items in the pathspec */
43 extern char *git_pathspec_prefix(const git_strarray
*pathspec
);
45 /* is there anything in the spec that needs to be filtered on */
46 extern bool git_pathspec_is_empty(const git_strarray
*pathspec
);
48 /* build a vector of fnmatch patterns to evaluate efficiently */
49 extern int git_pathspec__vinit(
50 git_vector
*vspec
, const git_strarray
*strspec
, git_pool
*strpool
);
52 /* free data from the pathspec vector */
53 extern void git_pathspec__vfree(git_vector
*vspec
);
55 #define GIT_PATHSPEC_NOMATCH ((size_t)-1)
58 * Match a path against the vectorized pathspec.
59 * The matched pathspec is passed back into the `matched_pathspec` parameter,
60 * unless it is passed as NULL by the caller.
62 extern bool git_pathspec__match(
63 const git_vector
*vspec
,
67 const char **matched_pathspec
,
70 /* easy pathspec setup */
72 extern int git_pathspec__init(git_pathspec
*ps
, const git_strarray
*paths
);
74 extern void git_pathspec__clear(git_pathspec
*ps
);