From fb898888491b83c9a3396fb559032ca78807a0c0 Mon Sep 17 00:00:00 2001 From: Samuel Lijin Date: Thu, 18 May 2017 04:21:52 -0400 Subject: dir: hide untracked contents of untracked dirs When we taught read_directory_recursive() to recurse into untracked directories in search of ignored files given DIR_SHOW_IGNORED_TOO, that had the side effect of teaching it to collect the untracked contents of untracked directories. It doesn't always make sense to return these, though (we do need them for `clean -d`), so we introduce a flag (DIR_KEEP_UNTRACKED_CONTENTS) to control whether or not read_directory() strips dir->entries of the untracked contents of untracked dirs. We also introduce check_contains() to check if one dir_entry corresponds to a path which contains the path corresponding to another dir_entry. This also fixes known breakages in t7061, since status --ignored now searches untracked directories for ignored files. Signed-off-by: Samuel Lijin Signed-off-by: Junio C Hamano --- dir.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'dir.h') diff --git a/dir.h b/dir.h index bf23a470af..650e54bdf6 100644 --- a/dir.h +++ b/dir.h @@ -151,7 +151,8 @@ struct dir_struct { DIR_NO_GITLINKS = 1<<3, DIR_COLLECT_IGNORED = 1<<4, DIR_SHOW_IGNORED_TOO = 1<<5, - DIR_COLLECT_KILLED_ONLY = 1<<6 + DIR_COLLECT_KILLED_ONLY = 1<<6, + DIR_KEEP_UNTRACKED_CONTENTS = 1<<7 } flags; struct dir_entry **entries; struct dir_entry **ignored; -- cgit v1.2.3 From bbf504a9957e8a2a262619641ffa30348d71a76f Mon Sep 17 00:00:00 2001 From: Samuel Lijin Date: Thu, 18 May 2017 04:21:53 -0400 Subject: dir: expose cmp_name() and check_contains() We want to use cmp_name() and check_contains() (which both compare `struct dir_entry`s, the former in terms of the sort order, the latter in terms of whether one lexically contains another) outside of dir.c, so we have to (1) change their linkage and (2) rename them as appropriate for the global namespace. The second is achieved by renaming cmp_name() to cmp_dir_entry() and check_contains() to check_dir_entry_contains(). Signed-off-by: Samuel Lijin Signed-off-by: Junio C Hamano --- dir.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'dir.h') diff --git a/dir.h b/dir.h index 650e54bdf6..edb5fda586 100644 --- a/dir.h +++ b/dir.h @@ -327,6 +327,9 @@ static inline int dir_path_match(const struct dir_entry *ent, has_trailing_dir); } +int cmp_dir_entry(const void *p1, const void *p2); +int check_dir_entry_contains(const struct dir_entry *out, const struct dir_entry *in); + void untracked_cache_invalidate_path(struct index_state *, const char *); void untracked_cache_remove_from_index(struct index_state *, const char *); void untracked_cache_add_to_index(struct index_state *, const char *); -- cgit v1.2.3