Skip to content

Commit 46af107

Browse files
peffgitster
authored andcommitted
docs/diff-options: clarify scope of diff-filter types
The same document for "--diff-filter" is included by many programs in the diff family. Because it mentions all possible types (added, removed, etc), this may imply to the reader that all types can be generated by a particular command. But this isn't necessarily the case; "diff-files" cannot generally produce an "Added" entry, since the diff is limited to what is already in the index. Let's make it clear that the list here is the full one, and does not imply anything about what a particular invocation may produce. Note that conditionally including items (e.g., omitting "Added" in the git-diff-files manpage) isn't the right solution here for two reasons: - The problem isn't diff-files, but doing an index to working tree diff. "git diff" can do the same diff, but also has other modes where "Added" does show up. - The direction of the diff matters. Doing "diff-files -R" can get you Added entries (but not Deleted ones). So it's best just to explain that the set of available types depends on the specific diff invocation. Reported-by: John Cheng <[email protected]> Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9752ad0 commit 46af107

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Documentation/diff-options.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,12 @@ ifndef::git-format-patch[]
422422
+
423423
Also, these upper-case letters can be downcased to exclude. E.g.
424424
`--diff-filter=ad` excludes added and deleted paths.
425+
+
426+
Note that not all diffs can feature all types. For instance, diffs
427+
from the index to the working tree can never have Added entries
428+
(because the set of paths included in the diff is limited by what is in
429+
the index). Similarly, copied and renamed entries cannot appear if
430+
detection for those types is disabled.
425431

426432
-S<string>::
427433
Look for differences that change the number of occurrences of

0 commit comments

Comments
 (0)