{"thread":{"id":"51151","subject":"strange behavior of git diff-index","startedAt":"2019-05-22T10:00:56Z","lastAt":"2019-05-22T15:27:57Z","messageCount":3,"participants":["Oussama Ghorbel","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"376055","messageId":"VI1PR08MB3454100258C23CB1F2B709F5EB000@VI1PR08MB3454.eurprd08.prod.outlook.com","threadId":"51151","inReplyTo":null,"subject":"strange behavior of git diff-index","fromName":"Oussama Ghorbel","fromEmail":"oussama.ghorbel@iopsys.eu","sentAt":"2019-05-22T10:00:50Z","receivedAt":"2019-05-22T10:00:56Z","isPatch":false,"sender":{"key":"oussama.ghorbel@iopsys.eu","avatar":null},"body":"Hi,\n\ngit diff-index is giving me incorrect information, however if I run git diff, then git diff-index again it will show the correct information.\nThe steps are the following:\n$ git diff-index --name-only HEAD\ngit appears to list all files in the project irrespective if they modified or not\n$ git diff\n$ git diff --cached\nwill show nothing. So I don't have any modification. \nNow strangely if I run git diff-index, it will also show nothing which is correction behavior.\n\nmy git version is 2.7.4\nAny explanation?\n\nThanks,\nOussama"},{"id":"376061","messageId":"nycvar.QRO.7.76.6.1905221651270.46@tvgsbejvaqbjf.bet","threadId":"51151","inReplyTo":"VI1PR08MB3454100258C23CB1F2B709F5EB000@VI1PR08MB3454.eurprd08.prod.outlook.com","subject":"Re: strange behavior of git diff-index","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-05-22T14:54:03Z","receivedAt":"2019-05-22T14:54:23Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Oussama,\n\nOn Wed, 22 May 2019, Oussama Ghorbel wrote:\n\n> git diff-index is giving me incorrect information, however if I run git diff, then git diff-index again it will show the correct information.\n> The steps are the following:\n> $ git diff-index --name-only HEAD\n> git appears to list all files in the project irrespective if they modified or not\n> $ git diff\n> $ git diff --cached\n> will show nothing. So I don't have any modification. \n> Now strangely if I run git diff-index, it will also show nothing which is correction behavior.\n>\n> my git version is 2.7.4\n> Any explanation?\n\nThe low-level `diff-index` command is meant to be used in scripts, and\ndoes specifically *not* refresh the index before running. Meaning that it\ncould possibly mistake a file for being modified even if it is not\nmodified, just because it is marked \"modified\" in the index [*1*].\n\nShort answer: use the high-level command `git diff` that is intended for\nhuman consumption.\n\nCiao,\nJohannes\n\nFootnote *1*: It is actually a bit more complicated than that: the index\nstores metadata such as mtime, size, uid, etc, and compares that to the\nmetadata on disk. If there is any mismatch, or if everything matches but\nthe mtime *also* matches the index file's itself, the file is considered\nnot up to date, i.e. marked as modified.\n"},{"id":"376062","messageId":"1b86251f-1b64-dfdf-7e40-e8a0c1e42e55@iopsys.eu","threadId":"51151","inReplyTo":"nycvar.QRO.7.76.6.1905221651270.46@tvgsbejvaqbjf.bet","subject":"Re: strange behavior of git diff-index","fromName":"Oussama Ghorbel","fromEmail":"oussama.ghorbel@iopsys.eu","sentAt":"2019-05-22T15:27:53Z","receivedAt":"2019-05-22T15:27:57Z","isPatch":false,"sender":{"key":"oussama.ghorbel@iopsys.eu","avatar":null},"body":"Hi Johannes,\n\nThanks a lot for the clarification!\n\nRegards,\nOussama\nOn 5/22/19 4:54 PM, Johannes Schindelin wrote:\n> Hi Oussama,\n>\n> On Wed, 22 May 2019, Oussama Ghorbel wrote:\n>\n>> git diff-index is giving me incorrect information, however if I run git diff, then git diff-index again it will show the correct information.\n>> The steps are the following:\n>> $ git diff-index --name-only HEAD\n>> git appears to list all files in the project irrespective if they modified or not\n>> $ git diff\n>> $ git diff --cached\n>> will show nothing. So I don't have any modification.\n>> Now strangely if I run git diff-index, it will also show nothing which is correction behavior.\n>>\n>> my git version is 2.7.4\n>> Any explanation?\n> The low-level `diff-index` command is meant to be used in scripts, and\n> does specifically *not* refresh the index before running. Meaning that it\n> could possibly mistake a file for being modified even if it is not\n> modified, just because it is marked \"modified\" in the index [*1*].\n>\n> Short answer: use the high-level command `git diff` that is intended for\n> human consumption.\n>\n> Ciao,\n> Johannes\n>\n> Footnote *1*: It is actually a bit more complicated than that: the index\n> stores metadata such as mtime, size, uid, etc, and compares that to the\n> metadata on disk. If there is any mismatch, or if everything matches but\n> the mtime *also* matches the index file's itself, the file is considered\n> not up to date, i.e. marked as modified.\n"}]}