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 <gitster@pobox.com> Signed-off-by: Manav Rathi <mnvrth@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Manav Rathi committed
Sep 25, 2017 at 13:39 UTC
93dbefb389a011c9107a3908fd38e743055be267
5 files changed
+24
-2
Documentation/git-add.txt
+3
@@ -61,6 +61,9 @@ OPTIONS
61
the working tree. Note that older versions of Git used
62
to ignore removed files; use `--no-all` option if you want
63
to add modified or new files but ignore removed ones.
64
++
65
+For more details about the <pathspec> syntax, see the 'pathspec' entry
66
+in linkgit:gitglossary[7].
67
68
-n::
69
--dry-run::
Documentation/git-grep.txt
+6
@@ -293,6 +293,9 @@ OPTIONS
293
<pathspec>...::
294
If given, limit the search to paths matching at least one pattern.
295
Both leading paths match and glob(7) patterns are supported.
296
++
297
+For more details about the <pathspec> syntax, see the 'pathspec' entry
298
+in linkgit:gitglossary[7].
299
300
Examples
301
--------
@@ -309,6 +312,9 @@ Examples
312
Looks for a line that has `NODE` or `Unexpected` in
313
files that have lines that match both.
314
315
+`git grep solution -- :^Documentation`::
316
+ Looks for `solution`, excluding files in `Documentation`.
317
+
318
GIT
319
---
320
Part of the linkgit:git[1] suite
Documentation/git-status.txt
+2
@@ -108,6 +108,8 @@ configuration variable documented in linkgit:git-config[1].
108
without options are equivalent to 'always' and 'never'
109
respectively.
110
111
+<pathspec>...::
112
+ See the 'pathspec' entry in linkgit:gitglossary[7].
113
114
OUTPUT
115
------
Documentation/glossary-content.txt
+1
-1
@@ -407,7 +407,7 @@ these forms:
407
408
exclude;;
409
After a path matches any non-exclude pathspec, it will be run
410
- through all exclude pathspec (magic signature: `!` or its
410
+ through all exclude pathspecs (magic signature: `!` or its
411
synonym `^`). If it matches, the path is ignored. When there
412
is no non-exclude pathspec, the exclusion is applied to the
413
result set as if invoked without any pathspec.
t/t6132-pathspec-exclude.sh
+12
-1
@@ -25,7 +25,7 @@ EOF
25
test_cmp expect actual
26
'
27
28
-test_expect_success 'exclude only no longer errors out' '
28
+test_expect_success 'exclude only pathspec uses default implicit pathspec' '
29
git log --oneline --format=%s -- . ":(exclude)sub" >expect &&
30
git log --oneline --format=%s -- ":(exclude)sub" >actual &&
31
test_cmp expect actual
@@ -183,4 +183,15 @@ EOF
183
test_cmp expect actual
184
'
185
186
+test_expect_success 'multiple exclusions' '
187
+ git ls-files -- ":^*/file2" ":^sub2" >actual &&
188
+ cat <<-\EOF >expect &&
189
+ file
190
+ sub/file
191
+ sub/sub/file
192
+ sub/sub/sub/file
193
+ EOF
194
+ test_cmp expect actual
195
+'
196
+
197
test_done