X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=dir.c;h=570b651a17520cbb0273b9247ab0fcffc0129477;hb=4868b2ea17b7a5e8171cb109423a25a269bfefe5;hp=852e60f2a8d4784bf73d044f89fe822538121286;hpb=47bfb3d946288ec359bf98d06cc668a2ba12f3cb;p=thirdparty%2Fgit.git diff --git a/dir.c b/dir.c index 852e60f2a8..570b651a17 100644 --- a/dir.c +++ b/dir.c @@ -253,6 +253,18 @@ static void *read_skip_worktree_file_from_index(const char *path, size_t *size) return data; } +void free_excludes(struct exclude_list *el) +{ + int i; + + for (i = 0; i < el->nr; i++) + free(el->excludes[i]); + free(el->excludes); + + el->nr = 0; + el->excludes = NULL; +} + int add_excludes_from_file_to_list(const char *fname, const char *base, int baselen, @@ -389,13 +401,6 @@ int excluded_from_list(const char *pathname, int to_exclude = x->to_exclude; if (x->flags & EXC_FLAG_MUSTBEDIR) { - if (!dtype) { - if (!prefixcmp(pathname, exclude) && - pathname[x->patternlen] == '/') - return to_exclude; - else - continue; - } if (*dtype == DT_UNKNOWN) *dtype = get_dtype(NULL, pathname, pathlen); if (*dtype != DT_DIR) @@ -1033,6 +1038,12 @@ char *get_relative_cwd(char *buffer, int size, const char *dir) case '/': return cwd + 1; default: + /* + * dir can end with a path separator when it's root + * directory. Return proper prefix in that case. + */ + if (dir[-1] == '/') + return cwd; return NULL; } }