]> git.proxmox.com Git - libgit2.git/blame - src/pathspec.h
install as examples
[libgit2.git] / src / pathspec.h
CommitLineData
2e3d4b96 1/*
359fc2d2 2 * Copyright (C) the libgit2 contributors. All rights reserved.
2e3d4b96
RB
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"
eae0bfdc
PP
11
12#include "git2/pathspec.h"
2e3d4b96
RB
13#include "buffer.h"
14#include "vector.h"
15#include "pool.h"
d2ce27dd
RB
16#include "array.h"
17
18/* public compiled pathspec */
19struct git_pathspec {
20 git_refcount rc;
21 char *prefix;
22 git_vector pathspec;
23 git_pool pool;
24};
25
2b672d5b
RB
26enum {
27 PATHSPEC_DATATYPE_STRINGS = 0,
28 PATHSPEC_DATATYPE_DIFF = 1,
29};
30
31typedef git_array_t(char *) git_pathspec_string_array_t;
32
d2ce27dd
RB
33/* public interface to pathspec matching */
34struct git_pathspec_match_list {
35 git_pathspec *pathspec;
2b672d5b
RB
36 git_array_t(void *) matches;
37 git_pathspec_string_array_t failures;
d2ce27dd 38 git_pool pool;
2b672d5b 39 int datatype;
d2ce27dd 40};
2e3d4b96
RB
41
42/* what is the common non-wildcard prefix for all items in the pathspec */
43extern char *git_pathspec_prefix(const git_strarray *pathspec);
44
45/* is there anything in the spec that needs to be filtered on */
0d32f39e 46extern bool git_pathspec_is_empty(const git_strarray *pathspec);
2e3d4b96
RB
47
48/* build a vector of fnmatch patterns to evaluate efficiently */
d2ce27dd 49extern int git_pathspec__vinit(
2e3d4b96
RB
50 git_vector *vspec, const git_strarray *strspec, git_pool *strpool);
51
52/* free data from the pathspec vector */
d2ce27dd
RB
53extern void git_pathspec__vfree(git_vector *vspec);
54
55#define GIT_PATHSPEC_NOMATCH ((size_t)-1)
2e3d4b96 56
943700ec 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 */
d2ce27dd
RB
62extern bool git_pathspec__match(
63 const git_vector *vspec,
943700ec 64 const char *path,
65 bool disable_fnmatch,
66 bool casefold,
d2ce27dd
RB
67 const char **matched_pathspec,
68 size_t *matched_at);
2e3d4b96 69
e91f9a8f
RB
70/* easy pathspec setup */
71
d2ce27dd 72extern int git_pathspec__init(git_pathspec *ps, const git_strarray *paths);
e91f9a8f 73
d2ce27dd 74extern void git_pathspec__clear(git_pathspec *ps);
e91f9a8f 75
2e3d4b96 76#endif