Reputation: 1148
Java files are listed in the known file types (using ag --list-file-types) but aren't aren't returned in the ag search results below unless I use the -t flag (-a and -U also return Java files in the results). Is this expected behavior? I have .gitignore files strewn about but this Java file is not being ignored in any of those files.
~/src $ ag "ACADEMIC"|grep java
~/src $ ag "ACADEMIC" -t|grep java
{path}/StudentRowMapper.java:23: Student.setAcademicLevel(rs.getString("ACADEMIC_LEVEL"));
Upvotes: 1
Views: 231
Reputation: 12973
No that is not expected behavior. And, in my quick test, not reproducing. Ag will search through .java files.
You don't need to specify searching java files. The "--java" file-type flag is for restricting a search to only .java and .properties files. For example:
~/src $ ag --java "ACADEMIC"
Since you're getting a result using -a or -U, but not without them, it appears as though you've got an .ignore file effecting ag. Ag ignores files include the following patterns: .gitignore, .hgignore, or .ignore. These files can be located anywhere in the directories searched. Also, keep in mind, binary files are ignored by default. In addition, ag looks in the file $HOME/.agignore for ignore patterns.
(From the man page:) If you want to ignore .gitignore and .hgignore, but still take .ignore into account, use -U flag. The -t option will search all text files; -a to search all files; and -u to search all, including hidden files.
Upvotes: 1