Blame src/pathspec.h

Packit Service 20376f
/*
Packit Service 20376f
 * Copyright (C) the libgit2 contributors. All rights reserved.
Packit Service 20376f
 *
Packit Service 20376f
 * This file is part of libgit2, distributed under the GNU GPL v2 with
Packit Service 20376f
 * a Linking Exception. For full terms see the included COPYING file.
Packit Service 20376f
 */
Packit Service 20376f
#ifndef INCLUDE_pathspec_h__
Packit Service 20376f
#define INCLUDE_pathspec_h__
Packit Service 20376f
Packit Service 20376f
#include "common.h"
Packit Service 20376f
#include <git2/pathspec.h>
Packit Service 20376f
#include "buffer.h"
Packit Service 20376f
#include "vector.h"
Packit Service 20376f
#include "pool.h"
Packit Service 20376f
#include "array.h"
Packit Service 20376f
Packit Service 20376f
/* public compiled pathspec */
Packit Service 20376f
struct git_pathspec {
Packit Service 20376f
	git_refcount rc;
Packit Service 20376f
	char *prefix;
Packit Service 20376f
	git_vector pathspec;
Packit Service 20376f
	git_pool pool;
Packit Service 20376f
};
Packit Service 20376f
Packit Service 20376f
enum {
Packit Service 20376f
	PATHSPEC_DATATYPE_STRINGS = 0,
Packit Service 20376f
	PATHSPEC_DATATYPE_DIFF = 1,
Packit Service 20376f
};
Packit Service 20376f
Packit Service 20376f
typedef git_array_t(char *) git_pathspec_string_array_t;
Packit Service 20376f
Packit Service 20376f
/* public interface to pathspec matching */
Packit Service 20376f
struct git_pathspec_match_list {
Packit Service 20376f
	git_pathspec *pathspec;
Packit Service 20376f
	git_array_t(void *) matches;
Packit Service 20376f
	git_pathspec_string_array_t failures;
Packit Service 20376f
	git_pool pool;
Packit Service 20376f
	int datatype;
Packit Service 20376f
};
Packit Service 20376f
Packit Service 20376f
/* what is the common non-wildcard prefix for all items in the pathspec */
Packit Service 20376f
extern char *git_pathspec_prefix(const git_strarray *pathspec);
Packit Service 20376f
Packit Service 20376f
/* is there anything in the spec that needs to be filtered on */
Packit Service 20376f
extern bool git_pathspec_is_empty(const git_strarray *pathspec);
Packit Service 20376f
Packit Service 20376f
/* build a vector of fnmatch patterns to evaluate efficiently */
Packit Service 20376f
extern int git_pathspec__vinit(
Packit Service 20376f
	git_vector *vspec, const git_strarray *strspec, git_pool *strpool);
Packit Service 20376f
Packit Service 20376f
/* free data from the pathspec vector */
Packit Service 20376f
extern void git_pathspec__vfree(git_vector *vspec);
Packit Service 20376f
Packit Service 20376f
#define GIT_PATHSPEC_NOMATCH ((size_t)-1)
Packit Service 20376f
Packit Service 20376f
/*
Packit Service 20376f
 * Match a path against the vectorized pathspec.
Packit Service 20376f
 * The matched pathspec is passed back into the `matched_pathspec` parameter,
Packit Service 20376f
 * unless it is passed as NULL by the caller.
Packit Service 20376f
 */
Packit Service 20376f
extern bool git_pathspec__match(
Packit Service 20376f
	const git_vector *vspec,
Packit Service 20376f
	const char *path,
Packit Service 20376f
	bool disable_fnmatch,
Packit Service 20376f
	bool casefold,
Packit Service 20376f
	const char **matched_pathspec,
Packit Service 20376f
	size_t *matched_at);
Packit Service 20376f
Packit Service 20376f
/* easy pathspec setup */
Packit Service 20376f
Packit Service 20376f
extern int git_pathspec__init(git_pathspec *ps, const git_strarray *paths);
Packit Service 20376f
Packit Service 20376f
extern void git_pathspec__clear(git_pathspec *ps);
Packit Service 20376f
Packit Service 20376f
#endif