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

diff --stat when chmoding binary files

From
MMMartin Mares <mj@ucw.cz>
Date
Aug 15, 2011, 08:50 UTC
Message-ID
<mj+md-20110815.084527.10358.albireo@ucw.cz>
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.
Message 1 of 1 in “diff --stat when chmoding binary files”
  1. Martin MaresAug 15, 2011

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.