]> git.proxmox.com Git - libgit2.git/blob - src/pathspec.h
Update branching information in d/gbp.conf
[libgit2.git] / src / pathspec.h
1 /*
2 * Copyright (C) the libgit2 contributors. All rights reserved.
3 *
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.
6 */
7 #ifndef INCLUDE_pathspec_h__
8 #define INCLUDE_pathspec_h__
9
10 #include "common.h"
11
12 #include "git2/pathspec.h"
13 #include "buffer.h"
14 #include "vector.h"
15 #include "pool.h"
16 #include "array.h"
17
18 /* public compiled pathspec */
19 struct git_pathspec {
20 git_refcount rc;
21 char *prefix;
22 git_vector pathspec;
23 git_pool pool;
24 };
25
26 enum {
27 PATHSPEC_DATATYPE_STRINGS = 0,
28 PATHSPEC_DATATYPE_DIFF = 1,
29 };
30
31 typedef git_array_t(char *) git_pathspec_string_array_t;
32
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;
38 git_pool pool;
39 int datatype;
40 };
41
42 /* what is the common non-wildcard prefix for all items in the pathspec */
43 extern char *git_pathspec_prefix(const git_strarray *pathspec);
44
45 /* is there anything in the spec that needs to be filtered on */
46 extern bool git_pathspec_is_empty(const git_strarray *pathspec);
47
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);
51
52 /* free data from the pathspec vector */
53 extern void git_pathspec__vfree(git_vector *vspec);
54
55 #define GIT_PATHSPEC_NOMATCH ((size_t)-1)
56
57 /*
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.
61 */
62 extern bool git_pathspec__match(
63 const git_vector *vspec,
64 const char *path,
65 bool disable_fnmatch,
66 bool casefold,
67 const char **matched_pathspec,
68 size_t *matched_at);
69
70 /* easy pathspec setup */
71
72 extern int git_pathspec__init(git_pathspec *ps, const git_strarray *paths);
73
74 extern void git_pathspec__clear(git_pathspec *ps);
75
76 #endif