threads / discuss / 28103

diff --stat when chmoding binary files

Subject: diff --stat when chmoding binary files

## tl;dr

One message between Aug 15, 2011 and Aug 15, 2011.

replies: 0people: 1as markdown or json

Martin Mares· Aug 15, 2011, 08:50 UTC · lore
Hello, world!\n

I have discovered somewhat surprising behavior of `git diff --stat' on files, which are not modified except for their executable bits. When the file is binary, it is listed in the diffstat, otherwise it is not.

For example:
| mj@albireo:/tmp$ mkdir gt
| mj@albireo:/tmp$ cd gt
| mj@albireo:/tmp/gt$ git init
| Initialized empty Git repository in /tmp/gt/.git/
| mj@albireo:/tmp/gt$ echo abcdef >a
| mj@albireo:/tmp/gt$ dd if=/dev/zero of=b bs=1024 count=1
| 1+0 records in
| 1+0 records out
| 1024 bytes (1.0 kB) copied, 7.3243e-05 s, 14.0 MB/s
| mj@albireo:/tmp/gt$ git add *
| mj@albireo:/tmp/gt$ git commit -m 'adding'
| [master (root-commit) 295d5f9] adding
|  2 files changed, 1 insertions(+), 0 deletions(-)
|  create mode 100644 a
|  create mode 100644 b
| mj@albireo:/tmp/gt$ chmod 755 *
| mj@albireo:/tmp/gt$ git add *
| mj@albireo:/tmp/gt$ git commit -m 'chmoding'
| [master 61c251b] chmoding
|  1 files changed, 0 insertions(+), 0 deletions(-)
|  mode change 100644 => 100755 a
|  mode change 100644 => 100755 b
| mj@albireo:/tmp/gt$ git diff HEAD^
| diff --git a/a b/a
| old mode 100644
| new mode 100755
| diff --git a/b b/b
| old mode 100644
| new mode 100755
| mj@albireo:/tmp/gt$ git diff --stat HEAD^
|  b |  Bin 1024 -> 1024 bytes
|  1 files changed, 0 insertions(+), 0 deletions(-)
This happens in git-1.7.6 and in several older versions as well.
Am I missing something or is it a bug?
				Have a nice fortnight
-- 
Martin `MJ' Mares                          <mj@ucw.cz>   http://mj.ucw.cz/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
Q: Who invented the first airplane that did not fly?  A: The Wrong Brothers.

← back to recent threads