summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-12-25 03:11:34 -0800
committerJunio C Hamano <junkio@cox.net>2006-12-25 03:29:08 -0800
commit4888c534099012d71d24051deb5b14319747bd1a (patch)
tree49dc638e23b71cc2609a797bfa7ca9f0ab72d072 /dir.c
parent08d22488a65fde7d570bd4ea57626f5352b9b064 (diff)
downloadgit-4888c534099012d71d24051deb5b14319747bd1a.tar.gz
read_directory: show_both option.
This teaches the internal read_directory() routine to return both interesting and ignored pathnames. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/dir.c b/dir.c
index 8477472c03..dd188a8c56 100644
--- a/dir.c
+++ b/dir.c
@@ -260,7 +260,8 @@ int excluded(struct dir_struct *dir, const char *pathname)
return 0;
}
-static void add_name(struct dir_struct *dir, const char *pathname, int len)
+static void add_name(struct dir_struct *dir, const char *pathname, int len,
+ int ignored_entry)
{
struct dir_entry *ent;
@@ -273,6 +274,7 @@ static void add_name(struct dir_struct *dir, const char *pathname, int len)
dir->entries = xrealloc(dir->entries, alloc*sizeof(ent));
}
ent = xmalloc(sizeof(*ent) + len + 1);
+ ent->ignored_entry = ignored_entry;
ent->len = len;
memcpy(ent->name, pathname, len);
ent->name[len] = 0;
@@ -314,6 +316,7 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co
while ((de = readdir(fdir)) != NULL) {
int len;
+ int ignored_entry;
if ((de->d_name[0] == '.') &&
(de->d_name[1] == 0 ||
@@ -322,11 +325,12 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co
continue;
len = strlen(de->d_name);
memcpy(fullname + baselen, de->d_name, len+1);
- if (excluded(dir, fullname) != dir->show_ignored) {
- if (!dir->show_ignored || DTYPE(de) != DT_DIR) {
- continue;
- }
- }
+ ignored_entry = excluded(dir, fullname);
+
+ if (!dir->show_both &&
+ (ignored_entry != dir->show_ignored) &&
+ (!dir->show_ignored || DTYPE(de) != DT_DIR))
+ continue;
switch (DTYPE(de)) {
struct stat st;
@@ -364,7 +368,8 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co
if (check_only)
goto exit_early;
else
- add_name(dir, fullname, baselen + len);
+ add_name(dir, fullname, baselen + len,
+ ignored_entry);
}
exit_early:
closedir(fdir);