#define USE_THE_REPOSITORY_VARIABLE
#include "git-compat-util.h"
#include "abspath.h"
#include "config.h"
#include "convert.h"
#include "dir.h"
#include "environment.h"
#include "gettext.h"
#include "name-hash.h"
#include "object-file.h"
#include "object-store-ll.h"
#include "path.h"
#include "refs.h"
#include "repository.h"
#include "wildmatch.h"
#include "pathspec.h"
#include "utf8.h"
#include "varint.h"
#include "ewah/ewok.h"
#include "fsmonitor-ll.h"
#include "read-cache-ll.h"
#include "setup.h"
#include "sparse-index.h"
#include "submodule-config.h"
#include "symlinks.h"
#include "trace2.h"
#include "tree.h"
#include "hex.h"
#define PATTERN_MAX_FILE_SIZE …
enum path_treatment { … };
struct cached_dir { … };
static enum path_treatment read_directory_recursive(struct dir_struct *dir,
struct index_state *istate, const char *path, int len,
struct untracked_cache_dir *untracked,
int check_only, int stop_at_first_file, const struct pathspec *pathspec);
static int resolve_dtype(int dtype, struct index_state *istate,
const char *path, int len);
struct dirent *readdir_skip_dot_and_dotdot(DIR *dirp)
{ … }
int count_slashes(const char *s)
{ … }
int git_fspathcmp(const char *a, const char *b)
{ … }
int fspatheq(const char *a, const char *b)
{ … }
int git_fspathncmp(const char *a, const char *b, size_t count)
{ … }
int paths_collide(const char *a, const char *b)
{ … }
unsigned int fspathhash(const char *str)
{ … }
int git_fnmatch(const struct pathspec_item *item,
const char *pattern, const char *string,
int prefix)
{ … }
static int fnmatch_icase_mem(const char *pattern, int patternlen,
const char *string, int stringlen,
int flags)
{ … }
static size_t common_prefix_len(const struct pathspec *pathspec)
{ … }
char *common_prefix(const struct pathspec *pathspec)
{ … }
int fill_directory(struct dir_struct *dir,
struct index_state *istate,
const struct pathspec *pathspec)
{ … }
int within_depth(const char *name, int namelen,
int depth, int max_depth)
{ … }
static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat,
size_t *size_out, char **data_out)
{ … }
#define DO_MATCH_EXCLUDE …
#define DO_MATCH_DIRECTORY …
#define DO_MATCH_LEADING_PATHSPEC …
static int match_pathspec_item(struct index_state *istate,
const struct pathspec_item *item, int prefix,
const char *name, int namelen, unsigned flags)
{ … }
static int do_match_pathspec(struct index_state *istate,
const struct pathspec *ps,
const char *name, int namelen,
int prefix, char *seen,
unsigned flags)
{ … }
static int match_pathspec_with_flags(struct index_state *istate,
const struct pathspec *ps,
const char *name, int namelen,
int prefix, char *seen, unsigned flags)
{ … }
int match_pathspec(struct index_state *istate,
const struct pathspec *ps,
const char *name, int namelen,
int prefix, char *seen, int is_dir)
{ … }
int submodule_path_match(struct index_state *istate,
const struct pathspec *ps,
const char *submodule_name,
char *seen)
{ … }
int report_path_error(const char *ps_matched,
const struct pathspec *pathspec)
{ … }
int simple_length(const char *match)
{ … }
int no_wildcard(const char *string)
{ … }
void parse_path_pattern(const char **pattern,
int *patternlen,
unsigned *flags,
int *nowildcardlen)
{ … }
int pl_hashmap_cmp(const void *cmp_data UNUSED,
const struct hashmap_entry *a,
const struct hashmap_entry *b,
const void *key UNUSED)
{ … }
static char *dup_and_filter_pattern(const char *pattern)
{ … }
static void clear_pattern_entry_hashmap(struct hashmap *map)
{ … }
static void add_pattern_to_hashsets(struct pattern_list *pl, struct path_pattern *given)
{ … }
static int hashmap_contains_path(struct hashmap *map,
struct strbuf *pattern)
{ … }
int hashmap_contains_parent(struct hashmap *map,
const char *path,
struct strbuf *buffer)
{ … }
void add_pattern(const char *string, const char *base,
int baselen, struct pattern_list *pl, int srcpos)
{ … }
static int read_skip_worktree_file_from_index(struct index_state *istate,
const char *path,
size_t *size_out, char **data_out,
struct oid_stat *oid_stat)
{ … }
void clear_pattern_list(struct pattern_list *pl)
{ … }
static void trim_trailing_spaces(char *buf)
{ … }
static struct untracked_cache_dir *lookup_untracked(struct untracked_cache *uc,
struct untracked_cache_dir *dir,
const char *name, int len)
{ … }
static void do_invalidate_gitignore(struct untracked_cache_dir *dir)
{ … }
static void invalidate_gitignore(struct untracked_cache *uc,
struct untracked_cache_dir *dir)
{ … }
static void invalidate_directory(struct untracked_cache *uc,
struct untracked_cache_dir *dir)
{ … }
static int add_patterns_from_buffer(char *buf, size_t size,
const char *base, int baselen,
struct pattern_list *pl);
#define PATTERN_NOFOLLOW …
static int add_patterns(const char *fname, const char *base, int baselen,
struct pattern_list *pl, struct index_state *istate,
unsigned flags, struct oid_stat *oid_stat)
{ … }
static int add_patterns_from_buffer(char *buf, size_t size,
const char *base, int baselen,
struct pattern_list *pl)
{ … }
int add_patterns_from_file_to_list(const char *fname, const char *base,
int baselen, struct pattern_list *pl,
struct index_state *istate,
unsigned flags)
{ … }
int add_patterns_from_blob_to_list(
struct object_id *oid,
const char *base, int baselen,
struct pattern_list *pl)
{ … }
struct pattern_list *add_pattern_list(struct dir_struct *dir,
int group_type, const char *src)
{ … }
static void add_patterns_from_file_1(struct dir_struct *dir, const char *fname,
struct oid_stat *oid_stat)
{ … }
void add_patterns_from_file(struct dir_struct *dir, const char *fname)
{ … }
int match_basename(const char *basename, int basenamelen,
const char *pattern, int prefix, int patternlen,
unsigned flags)
{ … }
int match_pathname(const char *pathname, int pathlen,
const char *base, int baselen,
const char *pattern, int prefix, int patternlen)
{ … }
static struct path_pattern *last_matching_pattern_from_list(const char *pathname,
int pathlen,
const char *basename,
int *dtype,
struct pattern_list *pl,
struct index_state *istate)
{ … }
enum pattern_match_result path_matches_pattern_list(
const char *pathname, int pathlen,
const char *basename, int *dtype,
struct pattern_list *pl,
struct index_state *istate)
{ … }
int init_sparse_checkout_patterns(struct index_state *istate)
{ … }
static int path_in_sparse_checkout_1(const char *path,
struct index_state *istate,
int require_cone_mode)
{ … }
int path_in_sparse_checkout(const char *path,
struct index_state *istate)
{ … }
int path_in_cone_mode_sparse_checkout(const char *path,
struct index_state *istate)
{ … }
static struct path_pattern *last_matching_pattern_from_lists(
struct dir_struct *dir, struct index_state *istate,
const char *pathname, int pathlen,
const char *basename, int *dtype_p)
{ … }
static void prep_exclude(struct dir_struct *dir,
struct index_state *istate,
const char *base, int baselen)
{ … }
struct path_pattern *last_matching_pattern(struct dir_struct *dir,
struct index_state *istate,
const char *pathname,
int *dtype_p)
{ … }
int is_excluded(struct dir_struct *dir, struct index_state *istate,
const char *pathname, int *dtype_p)
{ … }
static struct dir_entry *dir_entry_new(const char *pathname, int len)
{ … }
static struct dir_entry *dir_add_name(struct dir_struct *dir,
struct index_state *istate,
const char *pathname, int len)
{ … }
struct dir_entry *dir_add_ignored(struct dir_struct *dir,
struct index_state *istate,
const char *pathname, int len)
{ … }
enum exist_status { … };
static enum exist_status directory_exists_in_index_icase(struct index_state *istate,
const char *dirname, int len)
{ … }
static enum exist_status directory_exists_in_index(struct index_state *istate,
const char *dirname, int len)
{ … }
static enum path_treatment treat_directory(struct dir_struct *dir,
struct index_state *istate,
struct untracked_cache_dir *untracked,
const char *dirname, int len, int baselen, int excluded,
const struct pathspec *pathspec)
{ … }
static int simplify_away(const char *path, int pathlen,
const struct pathspec *pathspec)
{ … }
static int exclude_matches_pathspec(const char *path, int pathlen,
const struct pathspec *pathspec)
{ … }
static int get_index_dtype(struct index_state *istate,
const char *path, int len)
{ … }
unsigned char get_dtype(struct dirent *e, struct strbuf *path,
int follow_symlink)
{ … }
static int resolve_dtype(int dtype, struct index_state *istate,
const char *path, int len)
{ … }
static enum path_treatment treat_path_fast(struct dir_struct *dir,
struct cached_dir *cdir,
struct index_state *istate,
struct strbuf *path,
int baselen,
const struct pathspec *pathspec)
{ … }
static enum path_treatment treat_path(struct dir_struct *dir,
struct untracked_cache_dir *untracked,
struct cached_dir *cdir,
struct index_state *istate,
struct strbuf *path,
int baselen,
const struct pathspec *pathspec)
{ … }
static void add_untracked(struct untracked_cache_dir *dir, const char *name)
{ … }
static int valid_cached_dir(struct dir_struct *dir,
struct untracked_cache_dir *untracked,
struct index_state *istate,
struct strbuf *path,
int check_only)
{ … }
static int open_cached_dir(struct cached_dir *cdir,
struct dir_struct *dir,
struct untracked_cache_dir *untracked,
struct index_state *istate,
struct strbuf *path,
int check_only)
{ … }
static int read_cached_dir(struct cached_dir *cdir)
{ … }
static void close_cached_dir(struct cached_dir *cdir)
{ … }
static void add_path_to_appropriate_result_list(struct dir_struct *dir,
struct untracked_cache_dir *untracked,
struct cached_dir *cdir,
struct index_state *istate,
struct strbuf *path,
int baselen,
const struct pathspec *pathspec,
enum path_treatment state)
{ … }
static enum path_treatment read_directory_recursive(struct dir_struct *dir,
struct index_state *istate, const char *base, int baselen,
struct untracked_cache_dir *untracked, int check_only,
int stop_at_first_file, const struct pathspec *pathspec)
{ … }
int cmp_dir_entry(const void *p1, const void *p2)
{ … }
int check_dir_entry_contains(const struct dir_entry *out, const struct dir_entry *in)
{ … }
static int treat_leading_path(struct dir_struct *dir,
struct index_state *istate,
const char *path, int len,
const struct pathspec *pathspec)
{ … }
static const char *get_ident_string(void)
{ … }
static int ident_in_untracked(const struct untracked_cache *uc)
{ … }
static void set_untracked_ident(struct untracked_cache *uc)
{ … }
static unsigned new_untracked_cache_flags(struct index_state *istate)
{ … }
static void new_untracked_cache(struct index_state *istate, int flags)
{ … }
void add_untracked_cache(struct index_state *istate)
{ … }
void remove_untracked_cache(struct index_state *istate)
{ … }
static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *dir,
int base_len,
const struct pathspec *pathspec,
struct index_state *istate)
{ … }
static void emit_traversal_statistics(struct dir_struct *dir,
struct repository *repo,
const char *path,
int path_len)
{ … }
int read_directory(struct dir_struct *dir, struct index_state *istate,
const char *path, int len, const struct pathspec *pathspec)
{ … }
int file_exists(const char *f)
{ … }
int repo_file_exists(struct repository *repo, const char *path)
{ … }
static int cmp_icase(char a, char b)
{ … }
int dir_inside_of(const char *subdir, const char *dir)
{ … }
int is_inside_dir(const char *dir)
{ … }
int is_empty_dir(const char *path)
{ … }
char *git_url_basename(const char *repo, int is_bundle, int is_bare)
{ … }
void strip_dir_trailing_slashes(char *dir)
{ … }
static int remove_dir_recurse(struct strbuf *path, int flag, int *kept_up)
{ … }
int remove_dir_recursively(struct strbuf *path, int flag)
{ … }
static GIT_PATH_FUNC(git_path_info_exclude, "info/exclude")
void setup_standard_excludes(struct dir_struct *dir)
{ … }
char *get_sparse_checkout_filename(void)
{ … }
int get_sparse_checkout_patterns(struct pattern_list *pl)
{ … }
int remove_path(const char *name)
{ … }
void dir_clear(struct dir_struct *dir)
{ … }
struct ondisk_untracked_cache { … };
#define ouc_offset(x) …
struct write_data { … };
static void stat_data_to_disk(struct stat_data *to, const struct stat_data *from)
{ … }
static void write_one_dir(struct untracked_cache_dir *untracked,
struct write_data *wd)
{ … }
void write_untracked_extension(struct strbuf *out, struct untracked_cache *untracked)
{ … }
static void free_untracked(struct untracked_cache_dir *ucd)
{ … }
void free_untracked_cache(struct untracked_cache *uc)
{ … }
struct read_data { … };
static void stat_data_from_disk(struct stat_data *to, const unsigned char *data)
{ … }
static int read_one_dir(struct untracked_cache_dir **untracked_,
struct read_data *rd)
{ … }
static void set_check_only(size_t pos, void *cb)
{ … }
static void read_stat(size_t pos, void *cb)
{ … }
static void read_oid(size_t pos, void *cb)
{ … }
static void load_oid_stat(struct oid_stat *oid_stat, const unsigned char *data,
const unsigned char *sha1)
{ … }
struct untracked_cache *read_untracked_extension(const void *data, unsigned long sz)
{ … }
static void invalidate_one_directory(struct untracked_cache *uc,
struct untracked_cache_dir *ucd)
{ … }
static int invalidate_one_component(struct untracked_cache *uc,
struct untracked_cache_dir *dir,
const char *path, int len)
{ … }
void untracked_cache_invalidate_path(struct index_state *istate,
const char *path, int safe_path)
{ … }
void untracked_cache_invalidate_trimmed_path(struct index_state *istate,
const char *path,
int safe_path)
{ … }
void untracked_cache_remove_from_index(struct index_state *istate,
const char *path)
{ … }
void untracked_cache_add_to_index(struct index_state *istate,
const char *path)
{ … }
static void connect_wt_gitdir_in_nested(const char *sub_worktree,
const char *sub_gitdir)
{ … }
void connect_work_tree_and_git_dir(const char *work_tree_,
const char *git_dir_,
int recurse_into_nested)
{ … }
void relocate_gitdir(const char *path, const char *old_git_dir, const char *new_git_dir)
{ … }
int path_match_flags(const char *const str, const enum path_match_flags flags)
{ … }