@matheusbsbs / matheus-bagliano / commits / cb09753423
Fork 0

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>

Nguyễn Thái Ngọc Duy committed Aug 20, 2009 at 20:47 UTC cb097534230a6bd7438e19ce6dff719697cbf983
2 files changed +20 -16
dir.c
+16 -16
@@ -223,12 +223,12 @@ static void *read_skip_worktree_file_from_index(const char *path, size_t *size)
223 return data;
224 }
225
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)
232 {
233 struct stat st;
234 int fd, i;
@@ -274,8 +274,8 @@ static int add_excludes_from_file_1(const char *fname,
274
275 void add_excludes_from_file(struct dir_struct *dir, const char *fname)
276 {
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)
279 die("cannot use %s as an exclude file", fname);
280 }
281
@@ -324,9 +324,9 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen)
324 memcpy(dir->basebuf + current, base + current,
325 stk->baselen - current);
326 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);
330 dir->exclude_stack = stk;
331 current = stk->baselen;
332 }
@@ -336,9 +336,9 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen)
336 /* Scan the list and let the last match determine the fate.
337 * Return 1 for exclude, 0 for include and -1 for undecided.
338 */
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)
342 {
343 int i;
344
@@ -412,8 +412,8 @@ int excluded(struct dir_struct *dir, const char *pathname, int *dtype_p)
412
413 prep_exclude(dir, pathname, basename-pathname);
414 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])) {
417 case 0:
418 return 0;
419 case 1:
dir.h
+4
@@ -69,7 +69,11 @@ extern int match_pathspec(const char **pathspec, const char *name, int namelen,
69 extern int fill_directory(struct dir_struct *dir, const char **pathspec);
70 extern int read_directory(struct dir_struct *, const char *path, int len, const char **pathspec);
71
72 +extern int excluded_from_list(const char *pathname, int pathlen, const char *basename,
73 + int *dtype, struct exclude_list *el);
74 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);
77 extern void add_excludes_from_file(struct dir_struct *, const char *fname);
78 extern void add_exclude(const char *string, const char *base,
79 int baselen, struct exclude_list *which);