{"thread":{"id":"58494","subject":"git diff-index considers touched files as dirty and changes behaviour","startedAt":"2022-09-22T14:12:02Z","lastAt":"2022-09-22T15:20:44Z","messageCount":2,"participants":["Lindeke, Cord","Phillip Wood"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"463445","messageId":"BEZP281MB25194116180654CE60001F6CEC4E9@BEZP281MB2519.DEUP281.PROD.OUTLOOK.COM","threadId":"58494","inReplyTo":null,"subject":"git diff-index considers touched files as dirty and changes behaviour","fromName":"Lindeke, Cord","fromEmail":"cord.lindeke@softwareag.com","sentAt":"2022-09-22T14:11:18Z","receivedAt":"2022-09-22T14:12:02Z","isPatch":false,"sender":{"key":"cord.lindeke@softwareag.com","avatar":null},"body":"What did you do before the bug happened? (Steps to reproduce your issue)\n> touch README.md\n> git diff-index --exit-code HEAD\n:100644 100644 64c1efecd5716f56155b806caaf9fa6a771fae47 0000000000000000000000000000000000000000 M      README.md\n> echo $?\n1\n> git status\nOn branch master\nYour branch is up to date with 'origin/master'.\n\nnothing to commit, working tree clean\n> git diff-index --exit-code HEAD\n> echo $?\n0\n\nWhat did you expect to happen? (Expected behavior)\nThe first \"git diff-index\" should not detect any differences, but return 0 instead.\n\nWhat happened instead? (Actual behavior)\nThe first \"git diff-index\" considers the touched README.md as dirty and returns 1.\nSomehow, calling \"git status\" fixes this behaviour so that the second \"git diff-index\" behaves as expected.\n\nWhat's different between what you expected and what actually happened?\nThe result of the first \"git diff-index\" should have been 0.\nAnd the behaviour should not alter at all with calling any other git commands like \"git status\" or \"git diff\" in between.\n\nAnything else you want to add:\nThe same issue holds true for \"git diff-files\".\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.37.3\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Linux 4.15.0-193-generic #204-Ubuntu SMP Fri Aug 26 19:20:21 UTC 2022 x86_64\ncompiler info: gnuc: 7.5\nlibc info: glibc: 2.27\n$SHELL (typically, interactive shell): /bin/bash\n\n\n[Enabled Hooks]\n\nBest regards\nCord Lindeke\nSr. Software Specialist\ncord.lindeke@softwareag.com\nSoftware AG, Uhlandstrasse 12, 64297 Darmstadt, Germany\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nSoftware 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\n"},{"id":"463448","messageId":"9501804c-4b34-0c46-b75c-5b2eb23386b3@dunelm.org.uk","threadId":"58494","inReplyTo":"BEZP281MB25194116180654CE60001F6CEC4E9@BEZP281MB2519.DEUP281.PROD.OUTLOOK.COM","subject":"Re: git diff-index considers touched files as dirty and changes behaviour","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2022-09-22T15:20:11Z","receivedAt":"2022-09-22T15:20:44Z","isPatch":false,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi Cord\n\nOn 22/09/2022 15:11, Lindeke, Cord wrote:\n> What did you do before the bug happened? (Steps to reproduce your issue)\n>> touch README.md\n>> git diff-index --exit-code HEAD\n> :100644 100644 64c1efecd5716f56155b806caaf9fa6a771fae47 0000000000000000000000000000000000000000 M      README.md\n>> echo $?\n> 1\n>> git status\n> On branch master\n> Your branch is up to date with 'origin/master'.\n> \n> nothing to commit, working tree clean\n>> git diff-index --exit-code HEAD\n>> echo $?\n> 0\n> \n> What did you expect to happen? (Expected behavior)\n> The first \"git diff-index\" should not detect any differences, but return 0 instead.\n> \n> What happened instead? (Actual behavior)\n> The first \"git diff-index\" considers the touched README.md as dirty and returns 1.\n> Somehow, calling \"git status\" fixes this behaviour so that the second \"git diff-index\" behaves as expected.\n> \n> What's different between what you expected and what actually happened?\n> The result of the first \"git diff-index\" should have been 0.\n> And the behaviour should not alter at all with calling any other git commands like \"git status\" or \"git diff\" in between.\n\nIt is working as expected. diff-files and diff-index are \"plumbing\" \ncommands designed for use in scripts and require the index to be \nrefreshed with \"git update-index --refresh\" before they are called. \"git \ndiff\" and \"git status\" are \"porcelain\" commands designed for users and \nrefresh the index as the first step.\n\nBest Wishes\n\nPhillip\n\n\n> Anything else you want to add:\n> The same issue holds true for \"git diff-files\".\n> \n> Please review the rest of the bug report below.\n> You can delete any lines you don't wish to share.\n> \n> \n> [System Info]\n> git version:\n> git version 2.37.3\n> cpu: x86_64\n> no commit associated with this build\n> sizeof-long: 8\n> sizeof-size_t: 8\n> shell-path: /bin/sh\n> uname: Linux 4.15.0-193-generic #204-Ubuntu SMP Fri Aug 26 19:20:21 UTC 2022 x86_64\n> compiler info: gnuc: 7.5\n> libc info: glibc: 2.27\n> $SHELL (typically, interactive shell): /bin/bash\n> \n> \n> [Enabled Hooks]\n> \n> Best regards\n> Cord Lindeke\n> Sr. Software Specialist\n> cord.lindeke@softwareag.com\n> Software AG, Uhlandstrasse 12, 64297 Darmstadt, Germany\n> \n> \n> \n> \n> \n> \n> \n> \n> \n> \n> \n> \n> \n> \n> \n> 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\n"}]}