Skip to content

Commit

Permalink
Teach git-grep --name-only as synonym for -l
Browse files Browse the repository at this point in the history
I expected git grep --name-only to give me only the file names,
much as git diff --name-only only generates filenames.  Alas the
option is -l, which matches common external greps but doesn't match
other parts of the git UI.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
spearce authored and gitster committed Feb 21, 2008
1 parent 14a5c7c commit 2cd5dfd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Documentation/git-grep.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ OPTIONS
-n::
Prefix the line number to matching lines.

-l | --files-with-matches | -L | --files-without-match::
-l | --files-with-matches | --name-only | -L | --files-without-match::
Instead of showing every matched line, show only the
names of files that contain (or do not contain) matches.
For better compatability with git-diff, --name-only is a
synonym for --files-with-matches.

-c | --count::
Instead of showing every matched line, show the number of
Expand Down
1 change: 1 addition & 0 deletions builtin-grep.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
continue;
}
if (!strcmp("-l", arg) ||
!strcmp("--name-only", arg) ||
!strcmp("--files-with-matches", arg)) {
opt.name_only = 1;
continue;
Expand Down

0 comments on commit 2cd5dfd

Please sign in to comment.