{"thread":{"id":"55264","subject":"\"git diff-files\" command reports differences that don't exist","startedAt":"2021-03-05T19:29:27Z","lastAt":"2021-03-05T22:29:16Z","messageCount":5,"participants":["Michael Brown","Junio C Hamano","Eric Sunshine"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"418336","messageId":"4210f5f1-dd7e-f425-6ab2-e220a33e82bf@discourse.org","threadId":"55264","inReplyTo":null,"subject":"\"git diff-files\" command reports differences that don't exist","fromName":"Michael Brown","fromEmail":"michael.brown@discourse.org","sentAt":"2021-03-05T19:28:20Z","receivedAt":"2021-03-05T19:29:27Z","isPatch":false,"sender":{"key":"michael.brown@discourse.org","avatar":null},"body":"What did you do before the bug happened? (Steps to reproduce your issue)\n\n1. Be in any existing repository in a clean state (I tested with 2 existing\n   repositories and 1 completely fresh)\n1. run `git diff-files`, see no output\n1. touch an existing file: `touch a`\n1. run `git diff-files`\n\nWhat did you expect to happen? (Expected behavior)\n\n`git diff-files` should show no output\n\nWhat happened instead? (Actual behavior)\n\n`git diff-files` reported a difference on the touched file.\n\nWhat's different between what you expected and what actually happened?\n\ngit reports a difference where none exists\n\nAnything else you want to add:\n\nThis difference vanished after running other commands (e.g. `git diff`).\n\nA complete reproduction using docker is below:\n\n$ docker run -it --rm debian:latest\nroot@d24ec0793bdf:/# apt update && apt -y install git\n…\nroot@d24ec0793bdf:/# mkdir ~/new-repo\nroot@d24ec0793bdf:/# cd ~/new-repo\nroot@d24ec0793bdf:~/new-repo# git init\nInitialized empty Git repository in /root/new-repo/.git/\nroot@d24ec0793bdf:~/new-repo# touch a\nroot@d24ec0793bdf:~/new-repo# git add a\nroot@d24ec0793bdf:~/new-repo# git config --global user.email\n'user@example.net'\nroot@d24ec0793bdf:~/new-repo# git config --global user.name 'Example User'\nroot@d24ec0793bdf:~/new-repo# git commit -m 'initial'\n[master (root-commit) 791011f] initial\n 1 file changed, 0 insertions(+), 0 deletions(-)\n create mode 100644 a\nroot@d24ec0793bdf:~/new-repo# git diff-files\nroot@d24ec0793bdf:~/new-repo# touch a\nroot@d24ec0793bdf:~/new-repo# git diff-files\n:100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391\n0000000000000000000000000000000000000000 M    a\nroot@d24ec0793bdf:~/new-repo# git diff\nroot@d24ec0793bdf:~/new-repo# git diff-files\nroot@d24ec0793bdf:~/new-repo# git --version\ngit version 2.20.1\n\n\n[System Info]\ngit version:\ngit version 2.30.1\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Linux 5.11.1-arch1-1 #1 SMP PREEMPT Tue, 23 Feb 2021 14:05:30\n+0000 x86_64\ncompiler info: gnuc: 10.2\nlibc info: glibc: 2.33\n$SHELL (typically, interactive shell): /bin/bash\n\nThis same behaviour was also found in:\n\n* 2.20.1\n* 2.25.1\n\n[Enabled Hooks]\n(none)\n\n-- \nMichael Brown\nCivilized Discourse Construction Kit, Inc.\nhttps://www.discourse.org/\n\n"},{"id":"418345","messageId":"xmqqa6rh9sph.fsf@gitster.c.googlers.com","threadId":"55264","inReplyTo":"4210f5f1-dd7e-f425-6ab2-e220a33e82bf@discourse.org","subject":"Re: \"git diff-files\" command reports differences that don't exist","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-03-05T21:49:30Z","receivedAt":"2021-03-05T21:50:16Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Brown <michael.brown@discourse.org> writes:\n\n> What did you do before the bug happened? (Steps to reproduce your issue)\n>\n> 1. Be in any existing repository in a clean state (I tested with 2 existing\n>    repositories and 1 completely fresh)\n> 1. run `git diff-files`, see no output\n> 1. touch an existing file: `touch a`\n> 1. run `git diff-files`\n\nThis is totally expected behaviour.  In general when you are working\nwith plumbing commands like diff-files and diff-index, you are\nexpected to do \"update-index --refresh\" upfront.\n\nA plumbing command \"git diff\" has an equivalent of \"update-index\n--refresh\" built into it, but the plumbing commands are designed\nto be used in scripts, and in order to allow scripting programmers\nto avoid making unnecessary \"update-index --refresh\", e.g.\n\n\tgit update-index --refresh\n\tgit diff-files | use diff-files output\n\tgit diff-index | use diff-index output\n\nthey leave it the responsibility of the calling script (or the end\nuser who directly use them from the command line) to refresh the\ncached stat information as necessary.\n\n\n\n"},{"id":"418350","messageId":"CAPig+cSRKJUhwMagx_h21pJbBiX9paA5cvDbudDNcRVea6g3Mg@mail.gmail.com","threadId":"55264","inReplyTo":"xmqqa6rh9sph.fsf@gitster.c.googlers.com","subject":"Re: \"git diff-files\" command reports differences that don't exist","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2021-03-05T22:18:13Z","receivedAt":"2021-03-05T22:19:24Z","isPatch":false,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Fri, Mar 5, 2021 at 4:50 PM Junio C Hamano <gitster@pobox.com> wrote:\n> This is totally expected behaviour.  In general when you are working\n> with plumbing commands like diff-files and diff-index, you are\n> expected to do \"update-index --refresh\" upfront.\n>\n> A plumbing command \"git diff\" has an equivalent of \"update-index\n> --refresh\" built into it, but the plumbing commands are designed\n> to be used in scripts, and in order to allow scripting programmers\n> to avoid making unnecessary \"update-index --refresh\", e.g.\n\nDid you mean:\n\n    A porcelain command \"git diff\" has an equivalent...\n\n?\n"},{"id":"418351","messageId":"b3774f98-d2aa-3ae2-2aa5-c80339684c50@discourse.org","threadId":"55264","inReplyTo":"xmqqa6rh9sph.fsf@gitster.c.googlers.com","subject":"Re: \"git diff-files\" command reports differences that don't exist","fromName":"Michael Brown","fromEmail":"michael.brown@discourse.org","sentAt":"2021-03-05T22:20:55Z","receivedAt":"2021-03-05T22:21:33Z","isPatch":false,"sender":{"key":"michael.brown@discourse.org","avatar":null},"body":"On 2021-03-05 4:49 p.m., Junio C Hamano wrote:\n> This is totally expected behaviour.  In general when you are working\n> with plumbing commands like diff-files and diff-index, you are\n> expected to do \"update-index --refresh\" upfront.\nThanks. I wondered if since it was a plumbing command there might have\nbeen something I was missing but didn't know where to look.\n\nCheers.\n\n-- \nMichael Brown\nCivilized Discourse Construction Kit, Inc.\nhttps://www.discourse.org/\n"},{"id":"418352","messageId":"xmqq1rct9qwh.fsf@gitster.c.googlers.com","threadId":"55264","inReplyTo":"CAPig+cSRKJUhwMagx_h21pJbBiX9paA5cvDbudDNcRVea6g3Mg@mail.gmail.com","subject":"Re: \"git diff-files\" command reports differences that don't exist","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-03-05T22:28:30Z","receivedAt":"2021-03-05T22:29:16Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n> On Fri, Mar 5, 2021 at 4:50 PM Junio C Hamano <gitster@pobox.com> wrote:\n>> This is totally expected behaviour.  In general when you are working\n>> with plumbing commands like diff-files and diff-index, you are\n>> expected to do \"update-index --refresh\" upfront.\n>>\n>> A plumbing command \"git diff\" has an equivalent of \"update-index\n>> --refresh\" built into it, but the plumbing commands are designed\n>> to be used in scripts, and in order to allow scripting programmers\n>> to avoid making unnecessary \"update-index --refresh\", e.g.\n>\n> Did you mean:\n>\n>     A porcelain command \"git diff\" has an equivalent...\n\nYes.\n"}]}