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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx'
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/




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux