Merge branch 'jm/status-ignored-files-list'

The set of paths output from "git status --ignored" was tied
closely with its "--untracked=<mode>" option, but now it can be
controlled more flexibly.  Most notably, a directory that is
ignored because it is listed to be ignored in the ignore/exclude
mechanism can be handled differently from a directory that ends up
to be ignored only because all files in it are ignored.

* jm/status-ignored-files-list:
  status: test ignored modes
  status: document options to show matching ignored files
  status: report matching ignored and normal untracked
  status: add option to show ignored files differently
This commit is contained in:
Junio C Hamano
2017-11-13 14:44:59 +09:00
8 changed files with 360 additions and 18 deletions

44
dir.c
View File

@ -1389,6 +1389,30 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
case index_nonexistent:
if (dir->flags & DIR_SHOW_OTHER_DIRECTORIES)
break;
if (exclude &&
(dir->flags & DIR_SHOW_IGNORED_TOO) &&
(dir->flags & DIR_SHOW_IGNORED_TOO_MODE_MATCHING)) {
/*
* This is an excluded directory and we are
* showing ignored paths that match an exclude
* pattern. (e.g. show directory as ignored
* only if it matches an exclude pattern).
* This path will either be 'path_excluded`
* (if we are showing empty directories or if
* the directory is not empty), or will be
* 'path_none' (empty directory, and we are
* not showing empty directories).
*/
if (!(dir->flags & DIR_HIDE_EMPTY_DIRECTORIES))
return path_excluded;
if (read_directory_recursive(dir, istate, dirname, len,
untracked, 1, 1, pathspec) == path_excluded)
return path_excluded;
return path_none;
}
if (!(dir->flags & DIR_NO_GITLINKS)) {
struct object_id oid;
if (resolve_gitlink_ref(dirname, "HEAD", &oid) == 0)
@ -1561,6 +1585,7 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
{
int exclude;
int has_path_in_index = !!index_file_exists(istate, path->buf, path->len, ignore_case);
enum path_treatment path_treatment;
if (dtype == DT_UNKNOWN)
dtype = get_dtype(de, istate, path->buf, path->len);
@ -1607,8 +1632,23 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
return path_none;
case DT_DIR:
strbuf_addch(path, '/');
return treat_directory(dir, istate, untracked, path->buf, path->len,
baselen, exclude, pathspec);
path_treatment = treat_directory(dir, istate, untracked,
path->buf, path->len,
baselen, exclude, pathspec);
/*
* If 1) we only want to return directories that
* match an exclude pattern and 2) this directory does
* not match an exclude pattern but all of its
* contents are excluded, then indicate that we should
* recurse into this directory (instead of marking the
* directory itself as an ignored path).
*/
if (!exclude &&
path_treatment == path_excluded &&
(dir->flags & DIR_SHOW_IGNORED_TOO) &&
(dir->flags & DIR_SHOW_IGNORED_TOO_MODE_MATCHING))
return path_recurse;
return path_treatment;
case DT_REG:
case DT_LNK:
return exclude ? path_excluded : path_untracked;