git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git file listing is inconsistent

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Nov 26, 2014, 21:55 UTC
Message-ID
<20141126215520.GS6527@google.com>
In-Reply-To
<CAGOJM6+DTSn2qa-KTWceqyraaugX_YVZhirkdc+t+cDfFB4OyQ@mail.gmail.com>
Hi Woody,
Woody Gilk wrote:
Show 5 quoted lines
> git diff --name-only
> git grep --files-with-matches
>
> I think --files-with-matches should be deprecated and replaced with
> --name-only for consistency.
See the (non-git) diff(1) and grep(1) manpages.

It might make sense for 'git grep' to learn --name-only too as a synonym to help muscle memory, though.

*looks*

Actually, 'git grep -h' tells me that git grep --name-only is already accepted as a synonym for --files-with-matches, ever since

 $ git log -Sname-only -- builtin-grep.c
[...]
 commit 2cd5dfd240ecb63c77bcb2532664984e3b69ae47
 Author: Shawn O. Pearce <spearce@spearce.org>
 Date:   Wed Feb 20 23:28:07 2008 -0500
     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.
     Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
     Signed-off-by: Junio C Hamano <gitster@pobox.com>
(v1.5.5-rc0~171).  Have you tried it?
Would something like the following patch help?
-- >8 --
Subject: grep doc: add reminder about --name-only option

Since v1.5.5-rc0~171 (2008-02-20), "git grep" accepts --name-only as a synonym for the GNU-style --files-with-matches, but because the synonym is not mentioned in the manpage synopsis it is hard to find.

Reported-by: Woody Gilk <woody.gilk@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 Documentation/git-grep.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt
index 31811f1..8060efe 100644
--- a/Documentation/git-grep.txt
+++ b/Documentation/git-grep.txt
@@ -14,7 +14,7 @@ SYNOPSIS
 	   [-E | --extended-regexp] [-G | --basic-regexp]
 	   [-P | --perl-regexp]
 	   [-F | --fixed-strings] [-n | --line-number]
-	   [-l | --files-with-matches] [-L | --files-without-match]
+	   [-l | --files-with-matches | --name-only] [-L | --files-without-match]
 	   [(-O | --open-files-in-pager) [<pager>]]
 	   [-z | --null]
 	   [-c | --count] [--all-match] [-q | --quiet]
-- 
2.2.0.rc0.207.ga3a616c
Previous: Junio C HamanoNext: Woody Gilk
Message 3 of 5 in “git file listing is inconsistent”
  1. Woody GilkNov 26, 2014
  2. Junio C HamanoNov 26, 2014
  3. Jonathan NiederNov 26, 2014
  4. Woody GilkNov 26, 2014
  5. Scott SchmitNov 26, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.