Skip to contentSkip to conversation

Teach git-grep --name-only as synonym for -l

PATCH New Shawn O. Pearce 1 participant 1 message Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Teach git-grep --name-only as synonym for -l

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.

---
This time with documentation!

 Documentation/git-grep.txt |    4 +++-
 builtin-grep.c             |    1 +
 2 files changed, 4 insertions(+), 1 deletions(-)
Documentation/git-grep.txt +3 -1
index f3cb24f..71a7335 100644
@@ -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
builtin-grep.c +1 -0
index 9180b39..f4f4ecb 100644
@@ -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;
Signature · 1 line
1.5.4.2.232.g08e5