dir.c: export excluded_1() and add_excludes_from_file_1()
These functions are used to handle .gitignore. They are now exported so that sparse checkout can reuse. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
c84de70781
commit
cb09753423
10
dir.c
10
dir.c
|
@ -223,7 +223,7 @@ static void *read_skip_worktree_file_from_index(const char *path, size_t *size)
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int add_excludes_from_file_1(const char *fname,
|
int add_excludes_from_file_to_list(const char *fname,
|
||||||
const char *base,
|
const char *base,
|
||||||
int baselen,
|
int baselen,
|
||||||
char **buf_p,
|
char **buf_p,
|
||||||
|
@ -274,7 +274,7 @@ static int add_excludes_from_file_1(const char *fname,
|
||||||
|
|
||||||
void add_excludes_from_file(struct dir_struct *dir, const char *fname)
|
void add_excludes_from_file(struct dir_struct *dir, const char *fname)
|
||||||
{
|
{
|
||||||
if (add_excludes_from_file_1(fname, "", 0, NULL,
|
if (add_excludes_from_file_to_list(fname, "", 0, NULL,
|
||||||
&dir->exclude_list[EXC_FILE], 0) < 0)
|
&dir->exclude_list[EXC_FILE], 0) < 0)
|
||||||
die("cannot use %s as an exclude file", fname);
|
die("cannot use %s as an exclude file", fname);
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen)
|
||||||
memcpy(dir->basebuf + current, base + current,
|
memcpy(dir->basebuf + current, base + current,
|
||||||
stk->baselen - current);
|
stk->baselen - current);
|
||||||
strcpy(dir->basebuf + stk->baselen, dir->exclude_per_dir);
|
strcpy(dir->basebuf + stk->baselen, dir->exclude_per_dir);
|
||||||
add_excludes_from_file_1(dir->basebuf,
|
add_excludes_from_file_to_list(dir->basebuf,
|
||||||
dir->basebuf, stk->baselen,
|
dir->basebuf, stk->baselen,
|
||||||
&stk->filebuf, el, 1);
|
&stk->filebuf, el, 1);
|
||||||
dir->exclude_stack = stk;
|
dir->exclude_stack = stk;
|
||||||
|
@ -336,7 +336,7 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen)
|
||||||
/* Scan the list and let the last match determine the fate.
|
/* Scan the list and let the last match determine the fate.
|
||||||
* Return 1 for exclude, 0 for include and -1 for undecided.
|
* Return 1 for exclude, 0 for include and -1 for undecided.
|
||||||
*/
|
*/
|
||||||
static int excluded_1(const char *pathname,
|
int excluded_from_list(const char *pathname,
|
||||||
int pathlen, const char *basename, int *dtype,
|
int pathlen, const char *basename, int *dtype,
|
||||||
struct exclude_list *el)
|
struct exclude_list *el)
|
||||||
{
|
{
|
||||||
|
@ -412,7 +412,7 @@ int excluded(struct dir_struct *dir, const char *pathname, int *dtype_p)
|
||||||
|
|
||||||
prep_exclude(dir, pathname, basename-pathname);
|
prep_exclude(dir, pathname, basename-pathname);
|
||||||
for (st = EXC_CMDL; st <= EXC_FILE; st++) {
|
for (st = EXC_CMDL; st <= EXC_FILE; st++) {
|
||||||
switch (excluded_1(pathname, pathlen, basename,
|
switch (excluded_from_list(pathname, pathlen, basename,
|
||||||
dtype_p, &dir->exclude_list[st])) {
|
dtype_p, &dir->exclude_list[st])) {
|
||||||
case 0:
|
case 0:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
4
dir.h
4
dir.h
|
@ -69,7 +69,11 @@ extern int match_pathspec(const char **pathspec, const char *name, int namelen,
|
||||||
extern int fill_directory(struct dir_struct *dir, const char **pathspec);
|
extern int fill_directory(struct dir_struct *dir, const char **pathspec);
|
||||||
extern int read_directory(struct dir_struct *, const char *path, int len, const char **pathspec);
|
extern int read_directory(struct dir_struct *, const char *path, int len, const char **pathspec);
|
||||||
|
|
||||||
|
extern int excluded_from_list(const char *pathname, int pathlen, const char *basename,
|
||||||
|
int *dtype, struct exclude_list *el);
|
||||||
extern int excluded(struct dir_struct *, const char *, int *);
|
extern int excluded(struct dir_struct *, const char *, int *);
|
||||||
|
extern int add_excludes_from_file_to_list(const char *fname, const char *base, int baselen,
|
||||||
|
char **buf_p, struct exclude_list *which, int check_index);
|
||||||
extern void add_excludes_from_file(struct dir_struct *, const char *fname);
|
extern void add_excludes_from_file(struct dir_struct *, const char *fname);
|
||||||
extern void add_exclude(const char *string, const char *base,
|
extern void add_exclude(const char *string, const char *base,
|
||||||
int baselen, struct exclude_list *which);
|
int baselen, struct exclude_list *which);
|
||||||
|
|
Loading…
Reference in New Issue