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

"git diff-files" command reports differences that don't exist

From
MBMichael Brown <michael.brown@discourse.org>
Date
Mar 5, 2021, 19:28 UTC
Message-ID
<4210f5f1-dd7e-f425-6ab2-e220a33e82bf@discourse.org>
What did you do before the bug happened? (Steps to reproduce your issue)
1. Be in any existing repository in a clean state (I tested with 2 existing
   repositories and 1 completely fresh)
1. run `git diff-files`, see no output
1. touch an existing file: `touch a`
1. run `git diff-files`
What did you expect to happen? (Expected behavior)
`git diff-files` should show no output
What happened instead? (Actual behavior)
`git diff-files` reported a difference on the touched file.
What's different between what you expected and what actually happened?
git reports a difference where none exists
Anything else you want to add:
This difference vanished after running other commands (e.g. `git diff`).
A complete reproduction using docker is below:
$ docker run -it --rm debian:latest
root@d24ec0793bdf:/# apt update && apt -y install git
…
root@d24ec0793bdf:/# mkdir ~/new-repo
root@d24ec0793bdf:/# cd ~/new-repo
root@d24ec0793bdf:~/new-repo# git init
Initialized empty Git repository in /root/new-repo/.git/
root@d24ec0793bdf:~/new-repo# touch a
root@d24ec0793bdf:~/new-repo# git add a
root@d24ec0793bdf:~/new-repo# git config --global user.email
'user@example.net'
root@d24ec0793bdf:~/new-repo# git config --global user.name 'Example User'
root@d24ec0793bdf:~/new-repo# git commit -m 'initial'
[master (root-commit) 791011f] initial
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 a
root@d24ec0793bdf:~/new-repo# git diff-files
root@d24ec0793bdf:~/new-repo# touch a
root@d24ec0793bdf:~/new-repo# git diff-files
:100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
0000000000000000000000000000000000000000 M    a
root@d24ec0793bdf:~/new-repo# git diff
root@d24ec0793bdf:~/new-repo# git diff-files
root@d24ec0793bdf:~/new-repo# git --version
git version 2.20.1

[System Info] git version: git version 2.30.1 cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh uname: Linux 5.11.1-arch1-1 #1 SMP PREEMPT Tue, 23 Feb 2021 14:05:30 +0000 x86_64 compiler info: gnuc: 10.2 libc info: glibc: 2.33 $SHELL (typically, interactive shell): /bin/bash

This same behaviour was also found in:
* 2.20.1
* 2.25.1

[Enabled Hooks] (none)

-- 
Michael Brown
Civilized Discourse Construction Kit, Inc.
https://www.discourse.org/
Next: Junio C Hamano
Message 1 of 5 in “"git diff-files" command reports differences that don't exist”
  1. Michael BrownMar 5, 2021
  2. Junio C HamanoMar 5, 2021
  3. Eric SunshineMar 5, 2021
  4. Junio C HamanoMar 5, 2021
  5. Michael BrownMar 5, 2021

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.