From: Junio C Hamano Date: Mon, 14 Jan 2013 16:15:40 +0000 (-0800) Subject: Merge branch 'ap/status-ignored-in-ignored-directory' X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0a9a787fca09878f993ad37c71a9646277222a6b;p=git.git Merge branch 'ap/status-ignored-in-ignored-directory' Output from "git status --ignored" showed an unexpected interaction with "--untracked". * ap/status-ignored-in-ignored-directory: status: always report ignored tracked directories git-status: Test --ignored behavior dir.c: Make git-status --ignored more consistent --- 0a9a787fca09878f993ad37c71a9646277222a6b diff --cc dir.c index e883a9148,f836590b4..9dde68a2f --- a/dir.c +++ b/dir.c @@@ -1003,6 -857,45 +1027,45 @@@ static enum directory_treatment treat_d return show_directory; } + /* + * Decide what to do when we find a file while traversing the + * filesystem. Mostly two cases: + * + * 1. We are looking for ignored files + * (a) File is ignored, include it + * (b) File is in ignored path, include it + * (c) File is not ignored, exclude it + * + * 2. Other scenarios, include the file if not excluded + * + * Return 1 for exclude, 0 for include. + */ + static int treat_file(struct dir_struct *dir, struct strbuf *path, int exclude, int *dtype) + { + struct path_exclude_check check; + int exclude_file = 0; + + if (exclude) + exclude_file = !(dir->flags & DIR_SHOW_IGNORED); + else if (dir->flags & DIR_SHOW_IGNORED) { + /* Always exclude indexed files */ + struct cache_entry *ce = index_name_exists(&the_index, + path->buf, path->len, ignore_case); + + if (ce) + return 1; + + path_exclude_check_init(&check, dir); + - if (!path_excluded(&check, path->buf, path->len, dtype)) ++ if (!is_path_excluded(&check, path->buf, path->len, dtype)) + exclude_file = 1; + + path_exclude_check_clear(&check); + } + + return exclude_file; + } + /* * This is an inexact early pruning of any recursive directory * reading - if the path cannot possibly be in the pathspec,