git diff --name-status does not always list changed files
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>&1done
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.
Signature · 1 line
Sebastian Schuberth
Quoted 5 lines · Sebastian Schuberth
...
so I decided to fix these files in my clean working tree withfor i in
find . -iname "*.c" -o -iname "*.cc" -o -iname "*.cpp" -o -iname "*.h" -o -iname "*.hpp"; do
Quoted 8 lines
echo $i echo wq | ed $i > /dev/null 2>&1done
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
$ exitQuoted 5 lines · Junio C Hamano
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.
Signature · 1 line
Sebastian Schuberth
Quoted 8 lines · Sebastian Schuberth
Quoted 5 lines · Junio C Hamano
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/
Quoted 6 lines
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.
Quoted 12 lines
Quoted 12 lines
Quoted 5 lines · Junio C Hamano
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"
Quoted 8 lines
Quoted 2 lines
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.
Signature · 1 line
Sebastian Schuberth
Quoted 5 lines · Sebastian Schuberth
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.