# git diff --name-status does not always list changed files

6 messages from 2008-02-28 to 2008-02-28. Participants: Sebastian Schuberth, Junio C Hamano.
Thread: https://gitlist.dev/t/12364

## Sebastian Schuberth, 2008-02-28 14:47

Subject: git diff --name-status does not always list changed files
Message-ID: <fq6hhi$cub$1@ger.gmane.org>
URL: https://gitlist.dev/e/fq6hhi%24cub%241%40ger.gmane.org

```
Hi,

I was getting a lot of "no newline at end of file" warnings with GCC, so 
I decided to fix these files in my clean working tree with

for i in `find . -iname "*.c" -o -iname "*.cc" -o -iname "*.cpp" -o 
-iname "*.h" -o -iname "*.hpp"`; do
     echo $i
     echo wq | ed $i > /dev/null 2>&1
done

Afterwards, I wanted so see a list of files that were actually affected, 
but to my wonderment "git diff --name-status" did not list any files, 
although both "git diff" and "gitk" showed the diffs correctly.

Is this a bug in "--name-status" that is does not detected changes if 
only a final newline has been added, or am I missing something?

Thanks.

-- 
Sebastian Schuberth


```

## Junio C Hamano, 2008-02-28 19:33

Subject: Re: git diff --name-status does not always list changed files
Message-ID: <7vablkkhac.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vablkkhac.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <fq6hhi$cub$1@ger.gmane.org>

```
Sebastian Schuberth <sschuberth@gmail.com> writes:

> ...
> so I decided to fix these files in my clean working tree with
>
> for i in `find . -iname "*.c" -o -iname "*.cc" -o -iname "*.cpp" -o
> -iname "*.h" -o -iname "*.hpp"`; do
>     echo $i
>     echo wq | ed $i > /dev/null 2>&1
> done
>
> Afterwards, I wanted so see a list of files that were actually
> affected, but to my wonderment "git diff --name-status" did not list
> any files, although both "git diff" and "gitk" showed the diffs
> correctly.

Doesn't reproduce for me.

        $ rm -fr /var/tmp/j && mkdir -p /var/tmp/j && cd /var/tmp/j
        $ git init
        Initialized empty Git repository in .git/
        $ echo -n hello > world
        $ git add world
        $ od -c world
        0000000   h   e   l   l   o
        0000005
        $ echo wq | ed world
        Newline appended
        6
        6
        $ od -c world
        0000000   h   e   l   l   o  \n
        0000006
        $ git diff --name-status
        M	world
        $ git diff --raw
        :100644 100644 b6fc4c6... 0000000... M	world
        $ exit


```

## Sebastian Schuberth, 2008-02-28 21:23

Subject: Re: git diff --name-status does not always list changed files
Message-ID: <bdca99240802281323x1ec904ddq914ac2c484e7c468@mail.gmail.com>
URL: https://gitlist.dev/e/bdca99240802281323x1ec904ddq914ac2c484e7c468%40mail.gmail.com
In-Reply-To: <7vablkkhac.fsf@gitster.siamese.dyndns.org>

```
Junio C Hamano wrote:

> Doesn't reproduce for me.
>
>         $ rm -fr /var/tmp/j && mkdir -p /var/tmp/j && cd /var/tmp/j
>         $ git init
>         Initialized empty Git repository in .git/

Can you reproduce it if you do

$ git config core.pager "less -F"

after "git init"? The "-F" seems to be important, but I'm not sure why
using this switch causes no files to be displayed in this case.

-- 
Sebastian Schuberth

```

## Junio C Hamano, 2008-02-28 21:42

Subject: Re: git diff --name-status does not always list changed files
Message-ID: <7vejawhi6a.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vejawhi6a.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <bdca99240802281323x1ec904ddq914ac2c484e7c468@mail.gmail.com>

```
"Sebastian Schuberth" <sschuberth@gmail.com> writes:

> Junio C Hamano wrote:
>
>> Doesn't reproduce for me.
>>
>>         $ rm -fr /var/tmp/j && mkdir -p /var/tmp/j && cd /var/tmp/j
>>         $ git init
>>         Initialized empty Git repository in .git/
>
> Can you reproduce it if you do
>
> $ git config core.pager "less -F"
>
> after "git init"? The "-F" seems to be important, but I'm not sure why
> using this switch causes no files to be displayed in this case.

Then isn't it what you are asking "less" to do?

Try "less -FX".  FYI, by default, we use "LESS=FRSX" exported
unless the user knows better than us and uses something of his
own.

```

## Sebastian Schuberth, 2008-02-28 22:19

Subject: Re: git diff --name-status does not always list changed files
Message-ID: <bdca99240802281419o3fcea2e8u277d8e5e48131b6d@mail.gmail.com>
URL: https://gitlist.dev/e/bdca99240802281419o3fcea2e8u277d8e5e48131b6d%40mail.gmail.com
In-Reply-To: <7vejawhi6a.fsf@gitster.siamese.dyndns.org>

```
>  > Junio C Hamano wrote:
>  >
>  >> Doesn't reproduce for me.
>  >>
>  >>         $ rm -fr /var/tmp/j && mkdir -p /var/tmp/j && cd /var/tmp/j
>  >>         $ git init
>  >>         Initialized empty Git repository in .git/
>  >
>  > Can you reproduce it if you do
>  >
>  > $ git config core.pager "less -F"
>  >
>  > after "git init"? The "-F" seems to be important, but I'm not sure why
>  > using this switch causes no files to be displayed in this case.
>
>  Then isn't it what you are asking "less" to do?
>
>  Try "less -FX".  FYI, by default, we use "LESS=FRSX" exported
>  unless the user knows better than us and uses something of his
>  own.

Thanks, -FX works, though I do not understand why it did not with just
-F. From what I understood, -F just makes "less" quit immediately
(instead of waiting for the user to press "q") if the lines to display
fit completely on screen. In no case it should display nothing if
there actually is something to display.

-- 
Sebastian Schuberth

```

## Junio C Hamano, 2008-02-28 22:51

Subject: Re: git diff --name-status does not always list changed files
Message-ID: <7v63w8hezn.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v63w8hezn.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <bdca99240802281419o3fcea2e8u277d8e5e48131b6d@mail.gmail.com>

```
"Sebastian Schuberth" <sschuberth@gmail.com> writes:

> Thanks, -FX works, though I do not understand why it did not with just
> -F. From what I understood, -F just makes "less" quit immediately
> (instead of waiting for the user to press "q") if the lines to display
> fit completely on screen. In no case it should display nothing if
> there actually is something to display.

My reading and understanding of less manual page, especially the
part that talks about -X suggests that everything is working as
it is meant to.

"git diff --name-status" displays something, less shows it, and
it quits immediately (because you asked it to with -F).  As part
of its quitting, it clears the screen because you did not ask
less not to do that by giving it an -X.

I am tempted to call it a bug in less, but I am a very nice
person and I would not actually do so ;-).  But it certainly
feels like a misfeature between less and terminfo to me.


```
