summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 453ec4b)
raw | patch | inline | side by side (parent: 453ec4b)
author | Linus Torvalds <torvalds@osdl.org> | |
Wed, 17 May 2006 02:46:16 +0000 (19:46 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Wed, 17 May 2006 08:56:55 +0000 (01:56 -0700) |
This moves the code to add the per-directory ignore files for the base
directory into the library routine.
That not only allows us to turn the function push_exclude_per_directory()
static again, it also simplifies the library interface a lot (the caller
no longer needs to worry about any of the per-directory exclude files at
all).
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
directory into the library routine.
That not only allows us to turn the function push_exclude_per_directory()
static again, it also simplifies the library interface a lot (the caller
no longer needs to worry about any of the per-directory exclude files at
all).
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
dir.c | patch | blob | history | |
dir.h | patch | blob | history | |
ls-files.c | patch | blob | history |
index 3f41a5dfea7fa99177e5549985ec7f6609e6c02c..d40b62e1c19c342dfddeb157b295d8188f9a1f20 100644 (file)
--- a/dir.c
+++ b/dir.c
die("cannot use %s as an exclude file", fname);
}
-int push_exclude_per_directory(struct dir_struct *dir, const char *base, int baselen)
+static int push_exclude_per_directory(struct dir_struct *dir, const char *base, int baselen)
{
char exclude_file[PATH_MAX];
struct exclude_list *el = &dir->exclude_list[EXC_DIRS];
int read_directory(struct dir_struct *dir, const char *path, const char *base, int baselen)
{
+ /*
+ * Make sure to do the per-directory exclude for all the
+ * directories leading up to our base.
+ */
+ if (baselen) {
+ if (dir->exclude_per_dir) {
+ char *p, *pp = xmalloc(baselen+1);
+ memcpy(pp, base, baselen+1);
+ p = pp;
+ while (1) {
+ char save = *p;
+ *p = 0;
+ push_exclude_per_directory(dir, pp, p-pp);
+ *p++ = save;
+ if (!save)
+ break;
+ p = strchr(p, '/');
+ if (p)
+ p++;
+ else
+ p = pp + baselen;
+ }
+ free(pp);
+ }
+ }
+
read_directory_recursive(dir, path, base, baselen);
qsort(dir->entries, dir->nr, sizeof(struct dir_entry *), cmp_name);
return dir->nr;
index e8fc441e7fcc4d53af30881a643853a0ab96f7aa..4f65f570852f417f70f1dadc80cc51be484454f1 100644 (file)
--- a/dir.h
+++ b/dir.h
extern void add_excludes_from_file(struct dir_struct *, const char *fname);
extern void add_exclude(const char *string, const char *base,
int baselen, struct exclude_list *which);
-extern int push_exclude_per_directory(struct dir_struct *,
- const char *base, int baselen);
#endif
diff --git a/ls-files.c b/ls-files.c
index 89941a3ff8baa023840c092f2b6964cb2b33cce4..dfe1481a353cb216e6967c172fe3426b76e4cedf 100644 (file)
--- a/ls-files.c
+++ b/ls-files.c
const char *path = ".", *base = "";
int baselen = prefix_len;
- if (baselen) {
+ if (baselen)
path = base = prefix;
- if (dir->exclude_per_dir) {
- char *p, *pp = xmalloc(baselen+1);
- memcpy(pp, prefix, baselen+1);
- p = pp;
- while (1) {
- char save = *p;
- *p = 0;
- push_exclude_per_directory(dir, pp, p-pp);
- *p++ = save;
- if (!save)
- break;
- p = strchr(p, '/');
- if (p)
- p++;
- else
- p = pp + baselen;
- }
- free(pp);
- }
- }
read_directory(dir, path, base, baselen);
if (show_others)
show_other_files(dir);