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

git diff-index considers touched files as dirty and changes behaviour

From
LCLindeke, Cord <cord.lindeke@softwareag.com>
Date
Sep 22, 2022, 14:11 UTC
Message-ID
<BEZP281MB25194116180654CE60001F6CEC4E9@BEZP281MB2519.DEUP281.PROD.OUTLOOK.COM>
What did you do before the bug happened? (Steps to reproduce your issue)
> touch README.md
> git diff-index --exit-code HEAD
:100644 100644 64c1efecd5716f56155b806caaf9fa6a771fae47 0000000000000000000000000000000000000000 M      README.md
> echo $?
1
> git status

On branch master Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
> git diff-index --exit-code HEAD
> echo $?
0

What did you expect to happen? (Expected behavior) The first "git diff-index" should not detect any differences, but return 0 instead.

What happened instead? (Actual behavior) The first "git diff-index" considers the touched README.md as dirty and returns 1. Somehow, calling "git status" fixes this behaviour so that the second "git diff-index" behaves as expected.

What's different between what you expected and what actually happened? The result of the first "git diff-index" should have been 0. And the behaviour should not alter at all with calling any other git commands like "git status" or "git diff" in between.

Anything else you want to add: The same issue holds true for "git diff-files".

Please review the rest of the bug report below. You can delete any lines you don't wish to share.

[System Info] git version: git version 2.37.3 cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh uname: Linux 4.15.0-193-generic #204-Ubuntu SMP Fri Aug 26 19:20:21 UTC 2022 x86_64 compiler info: gnuc: 7.5 libc info: glibc: 2.27 $SHELL (typically, interactive shell): /bin/bash

[Enabled Hooks]

Best regards Cord Lindeke Sr. Software Specialist cord.lindeke@softwareag.com Software AG, Uhlandstrasse 12, 64297 Darmstadt, Germany

Software AG – Sitz/Registered office: Uhlandstraße 12, 64297 Darmstadt, Germany – Registergericht/Commercial register: Darmstadt HRB 1562 - Vorstand/Management Board: Sanjay Brahmawar (Vorsitzender/Chairman), Dr. Elke Frank, Dr. Matthias Heiden, Dr. Stefan Sigg, Dr. Benno Quade, Joshua Husk - Aufsichtsratsvorsitzender/Chairman of the Supervisory Board: Christian Lucas - https://www.softwareag.com
Next: Phillip Wood
Message 1 of 2 in “git diff-index considers touched files as dirty and changes behaviour”
  1. Lindeke, CordSep 22, 2022
  2. Phillip WoodSep 22, 2022

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.