From 93dbefb389a011c9107a3908fd38e743055be267 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Mon, 25 Sep 2017 13:39:00 +0530 Subject: docs: improve discoverability of exclude pathspec The ability to exclude paths with a negative pathspec is not mentioned in the man pages for git grep and other commands where it might be useful. Add an example and a pointer to the pathspec glossary entry in the man page for git grep to help the user to discover this ability. Add similar pointers from the git-add and git-status man pages. Additionally, - Add a test for the behaviour when multiple exclusions are present. - Add a test for the ^ alias. - Improve name of existing test. - Improve grammar in glossary description of the exclude pathspec. Helped-by: Junio C Hamano Signed-off-by: Manav Rathi Signed-off-by: Junio C Hamano diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt index 7ed63dc..1c3da6d 100644 --- a/Documentation/git-add.txt +++ b/Documentation/git-add.txt @@ -61,6 +61,9 @@ OPTIONS the working tree. Note that older versions of Git used to ignore removed files; use `--no-all` option if you want to add modified or new files but ignore removed ones. ++ +For more details about the syntax, see the 'pathspec' entry +in linkgit:gitglossary[7]. -n:: --dry-run:: diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt index 71f32f3..56fb559 100644 --- a/Documentation/git-grep.txt +++ b/Documentation/git-grep.txt @@ -293,6 +293,9 @@ OPTIONS ...:: If given, limit the search to paths matching at least one pattern. Both leading paths match and glob(7) patterns are supported. ++ +For more details about the syntax, see the 'pathspec' entry +in linkgit:gitglossary[7]. Examples -------- @@ -309,6 +312,9 @@ Examples Looks for a line that has `NODE` or `Unexpected` in files that have lines that match both. +`git grep solution -- :^Documentation`:: + Looks for `solution`, excluding files in `Documentation`. + GIT --- Part of the linkgit:git[1] suite diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt index d70abc6..5440711 100644 --- a/Documentation/git-status.txt +++ b/Documentation/git-status.txt @@ -108,6 +108,8 @@ configuration variable documented in linkgit:git-config[1]. without options are equivalent to 'always' and 'never' respectively. +...:: + See the 'pathspec' entry in linkgit:gitglossary[7]. OUTPUT ------ diff --git a/Documentation/glossary-content.txt b/Documentation/glossary-content.txt index 6e991c2..39a6931 100644 --- a/Documentation/glossary-content.txt +++ b/Documentation/glossary-content.txt @@ -407,7 +407,7 @@ these forms: exclude;; After a path matches any non-exclude pathspec, it will be run - through all exclude pathspec (magic signature: `!` or its + through all exclude pathspecs (magic signature: `!` or its synonym `^`). If it matches, the path is ignored. When there is no non-exclude pathspec, the exclusion is applied to the result set as if invoked without any pathspec. diff --git a/t/t6132-pathspec-exclude.sh b/t/t6132-pathspec-exclude.sh index 9dd5cde..eb829fc 100755 --- a/t/t6132-pathspec-exclude.sh +++ b/t/t6132-pathspec-exclude.sh @@ -25,7 +25,7 @@ EOF test_cmp expect actual ' -test_expect_success 'exclude only no longer errors out' ' +test_expect_success 'exclude only pathspec uses default implicit pathspec' ' git log --oneline --format=%s -- . ":(exclude)sub" >expect && git log --oneline --format=%s -- ":(exclude)sub" >actual && test_cmp expect actual @@ -183,4 +183,15 @@ EOF test_cmp expect actual ' +test_expect_success 'multiple exclusions' ' + git ls-files -- ":^*/file2" ":^sub2" >actual && + cat <<-\EOF >expect && + file + sub/file + sub/sub/file + sub/sub/sub/file + EOF + test_cmp expect actual +' + test_done -- cgit v0.10.2-6-g49f6