Blame src/pathspec.h

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