# git file listing is inconsistent

5 messages from 2014-11-26 to 2014-11-26. Participants: Woody Gilk, Junio C Hamano, Jonathan Nieder, Scott Schmit.
Thread: https://gitlist.dev/t/38059

## Woody Gilk, 2014-11-26 21:10

Subject: git file listing is inconsistent
Message-ID: <CAGOJM6+DTSn2qa-KTWceqyraaugX_YVZhirkdc+t+cDfFB4OyQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAGOJM6%2BDTSn2qa-KTWceqyraaugX_YVZhirkdc%2Bt%2BcDfFB4OyQ%40mail.gmail.com

```
git diff --name-only
git grep --files-with-matches

I think --files-with-matches should be deprecated and replaced with
--name-only for consistency.

Thanks,
--
Woody Gilk
http://about.me/shadowhand

```

## Junio C Hamano, 2014-11-26 21:47

Subject: Re: git file listing is inconsistent
Message-ID: <xmqqd289prb2.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqd289prb2.fsf%40gitster.dls.corp.google.com
In-Reply-To: <CAGOJM6+DTSn2qa-KTWceqyraaugX_YVZhirkdc+t+cDfFB4OyQ@mail.gmail.com>

```
Woody Gilk <woody.gilk@gmail.com> writes:

> git diff --name-only
> git grep --files-with-matches
>
> I think --files-with-matches should be deprecated and replaced with
> --name-only for consistency.

That longer name comes from "GNU grep" consistency.

Why anybody does not use a shorter and sweeter "grep -l" is beyond
me, though ;-)

```

## Jonathan Nieder, 2014-11-26 21:55

Subject: Re: git file listing is inconsistent
Message-ID: <20141126215520.GS6527@google.com>
URL: https://gitlist.dev/e/20141126215520.GS6527%40google.com
In-Reply-To: <CAGOJM6+DTSn2qa-KTWceqyraaugX_YVZhirkdc+t+cDfFB4OyQ@mail.gmail.com>

```
Hi Woody,

Woody Gilk wrote:

> 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

```

## Scott Schmit, 2014-11-26 21:59

Subject: Re: git file listing is inconsistent
Message-ID: <20141126215949.GC3885@odin.ulthar.us>
URL: https://gitlist.dev/e/20141126215949.GC3885%40odin.ulthar.us
In-Reply-To: <CAGOJM6+DTSn2qa-KTWceqyraaugX_YVZhirkdc+t+cDfFB4OyQ@mail.gmail.com>

```
On Wed, Nov 26, 2014 at 03:10:33PM -0600, Woody Gilk wrote:
> git diff --name-only
> git grep --files-with-matches
> 
> I think --files-with-matches should be deprecated and replaced with
> --name-only for consistency.

git grep supports both: --name-only for consistency with other git
commands, and --files-with-matches for consistency with grep(1).

So I don't think anything needs to change.  All we need to do is to
teach grep(1) the --name-only option, and the cycle will be complete.
[I can never remember grep's version of the option...] :-D

-- 
Scott Schmit

```

## Woody Gilk, 2014-11-26 22:01

Subject: Re: git file listing is inconsistent
Message-ID: <CAGOJM6KokBxxaWn=j03CBEp0B5yjWWyMxS=H6KhXEW0r-OPjLw@mail.gmail.com>
URL: https://gitlist.dev/e/CAGOJM6KokBxxaWn%3Dj03CBEp0B5yjWWyMxS%3DH6KhXEW0r-OPjLw%40mail.gmail.com
In-Reply-To: <20141126215520.GS6527@google.com>

```
Jonathan,

On Wed, Nov 26, 2014 at 3:55 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Actually, 'git grep -h' tells me that git grep --name-only is already
> accepted as a synonym for --files-with-matches, ever since

You are absolutely right, it was a typo (and then not RTFM the
resulting help) on my part that caused the confusion.

Nothing needs to change here. :)
--
Woody Gilk
http://about.me/shadowhand

```
