Skip to content

Commit cb09753

Browse files
pcloudsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c84de70 commit cb09753

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

dir.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,12 @@ static void *read_skip_worktree_file_from_index(const char *path, size_t *size)
223223
return data;
224224
}
225225

226-
static int add_excludes_from_file_1(const char *fname,
227-
const char *base,
228-
int baselen,
229-
char **buf_p,
230-
struct exclude_list *which,
231-
int check_index)
226+
int add_excludes_from_file_to_list(const char *fname,
227+
const char *base,
228+
int baselen,
229+
char **buf_p,
230+
struct exclude_list *which,
231+
int check_index)
232232
{
233233
struct stat st;
234234
int fd, i;
@@ -274,8 +274,8 @@ static int add_excludes_from_file_1(const char *fname,
274274

275275
void add_excludes_from_file(struct dir_struct *dir, const char *fname)
276276
{
277-
if (add_excludes_from_file_1(fname, "", 0, NULL,
278-
&dir->exclude_list[EXC_FILE], 0) < 0)
277+
if (add_excludes_from_file_to_list(fname, "", 0, NULL,
278+
&dir->exclude_list[EXC_FILE], 0) < 0)
279279
die("cannot use %s as an exclude file", fname);
280280
}
281281

@@ -324,9 +324,9 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen)
324324
memcpy(dir->basebuf + current, base + current,
325325
stk->baselen - current);
326326
strcpy(dir->basebuf + stk->baselen, dir->exclude_per_dir);
327-
add_excludes_from_file_1(dir->basebuf,
328-
dir->basebuf, stk->baselen,
329-
&stk->filebuf, el, 1);
327+
add_excludes_from_file_to_list(dir->basebuf,
328+
dir->basebuf, stk->baselen,
329+
&stk->filebuf, el, 1);
330330
dir->exclude_stack = stk;
331331
current = stk->baselen;
332332
}
@@ -336,9 +336,9 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen)
336336
/* Scan the list and let the last match determine the fate.
337337
* Return 1 for exclude, 0 for include and -1 for undecided.
338338
*/
339-
static int excluded_1(const char *pathname,
340-
int pathlen, const char *basename, int *dtype,
341-
struct exclude_list *el)
339+
int excluded_from_list(const char *pathname,
340+
int pathlen, const char *basename, int *dtype,
341+
struct exclude_list *el)
342342
{
343343
int i;
344344

@@ -412,8 +412,8 @@ int excluded(struct dir_struct *dir, const char *pathname, int *dtype_p)
412412

413413
prep_exclude(dir, pathname, basename-pathname);
414414
for (st = EXC_CMDL; st <= EXC_FILE; st++) {
415-
switch (excluded_1(pathname, pathlen, basename,
416-
dtype_p, &dir->exclude_list[st])) {
415+
switch (excluded_from_list(pathname, pathlen, basename,
416+
dtype_p, &dir->exclude_list[st])) {
417417
case 0:
418418
return 0;
419419
case 1:

dir.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ extern int match_pathspec(const char **pathspec, const char *name, int namelen,
6969
extern int fill_directory(struct dir_struct *dir, const char **pathspec);
7070
extern int read_directory(struct dir_struct *, const char *path, int len, const char **pathspec);
7171

72+
extern int excluded_from_list(const char *pathname, int pathlen, const char *basename,
73+
int *dtype, struct exclude_list *el);
7274
extern int excluded(struct dir_struct *, const char *, int *);
75+
extern int add_excludes_from_file_to_list(const char *fname, const char *base, int baselen,
76+
char **buf_p, struct exclude_list *which, int check_index);
7377
extern void add_excludes_from_file(struct dir_struct *, const char *fname);
7478
extern void add_exclude(const char *string, const char *base,
7579
int baselen, struct exclude_list *which);

0 commit comments

Comments
 (0)