{"thread":{"id":"50178","subject":"`git reset` for delete + intent-to-add doesn't reset","startedAt":"2019-01-08T07:25:21Z","lastAt":"2019-01-08T10:06:30Z","messageCount":4,"participants":["Anthony Sottile","Duy Nguyen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"366319","messageId":"CA+dzEBmVQ8H78uHSPSBy+HqLXZ3xE5=jVdYDfPOVZ_53U8YA-A@mail.gmail.com","threadId":"50178","inReplyTo":null,"subject":"`git reset` for delete + intent-to-add doesn't reset","fromName":"Anthony Sottile","fromEmail":"asottile@umich.edu","sentAt":"2019-01-08T07:25:21Z","receivedAt":"2019-01-08T07:25:21Z","isPatch":false,"sender":{"key":"asottile@umich.edu","avatar":"https://avatars.githubusercontent.com/u/1810591?v=4"},"body":"```\ngit --version\nrm -rf t\ngit init t\ncd t\ntouch a\ngit add a\ngit commit -m \"add a\"\ngit rm a\ntouch a\ngit add --intent-to-add a\ngit status --short\ngit reset -- a\ngit status --short\n```\n\n(the git version below is compiled from\necbdaf0899161c067986e9d9d564586d4b045d62)\n\n```\n$ bash -x t.sh\n+ git --version\ngit version 2.20.GIT\n+ rm -rf t\n+ git init t\nInitialized empty Git repository in /tmp/t/t/.git/\n+ cd t\n+ touch a\n+ git add a\n+ git commit -m 'add a'\n[master (root-commit) 95a1815] add a\n 1 file changed, 0 insertions(+), 0 deletions(-)\n create mode 100644 a\n+ git rm a\nrm 'a'\n+ touch a\n+ git add --intent-to-add a\n+ git status --short\nDA a\n+ git reset -- a\nUnstaged changes after reset:\nA    a\n+ git status --short\nDA a\n```\n\nEven `git reset --intent-to-add -- a` or `git checkout -- a` don't\nseem to clear the `intent-to-add` state\n\nHow do I reset the intent-to-add status in this case?\n\nAnthony\n"},{"id":"366321","messageId":"CA+dzEB=fM_hD6P=fCvOtDrEAKa4eOgErmp8=nzRfoxOJHAG_zg@mail.gmail.com","threadId":"50178","inReplyTo":"CA+dzEBmVQ8H78uHSPSBy+HqLXZ3xE5=jVdYDfPOVZ_53U8YA-A@mail.gmail.com","subject":"Re: `git reset` for delete + intent-to-add doesn't reset","fromName":"Anthony Sottile","fromEmail":"asottile@umich.edu","sentAt":"2019-01-08T07:29:47Z","receivedAt":"2019-01-08T07:29:47Z","isPatch":false,"sender":{"key":"asottile@umich.edu","avatar":"https://avatars.githubusercontent.com/u/1810591?v=4"},"body":"On Mon, Jan 7, 2019 at 11:25 PM Anthony Sottile <asottile@umich.edu> wrote:\n> Even `git reset --intent-to-add -- a` or `git checkout -- a` don't\n> seem to clear the `intent-to-add` state\n>\n> How do I reset the intent-to-add status in this case?\n>\n> Anthony\n\nPressed send too quickly, it appears I can use `git rm --cached -- a`\nto undo that.\n"},{"id":"366322","messageId":"CACsJy8Atwp1nQbDaxYSNiDFmVmMG2h88w=dAZWU1SF6JQ18EEw@mail.gmail.com","threadId":"50178","inReplyTo":"CA+dzEBmVQ8H78uHSPSBy+HqLXZ3xE5=jVdYDfPOVZ_53U8YA-A@mail.gmail.com","subject":"Re: `git reset` for delete + intent-to-add doesn't reset","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2019-01-08T09:44:22Z","receivedAt":"2019-01-08T09:44:50Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Jan 8, 2019 at 2:28 PM Anthony Sottile <asottile@umich.edu> wrote:\n>\n> ```\n> git --version\n> rm -rf t\n> git init t\n> cd t\n> touch a\n> git add a\n> git commit -m \"add a\"\n> git rm a\n> touch a\n> git add --intent-to-add a\n> git status --short\n> git reset -- a\n\n\"git reset\" without \"-- a\" does remove intent-to-add status. I'll look\ninto whether \"reset -- a\" should do the same.\n\n> git status --short\n> ```\n>\n> (the git version below is compiled from\n> ecbdaf0899161c067986e9d9d564586d4b045d62)\n>\n> ```\n> $ bash -x t.sh\n> + git --version\n> git version 2.20.GIT\n> + rm -rf t\n> + git init t\n> Initialized empty Git repository in /tmp/t/t/.git/\n> + cd t\n> + touch a\n> + git add a\n> + git commit -m 'add a'\n> [master (root-commit) 95a1815] add a\n>  1 file changed, 0 insertions(+), 0 deletions(-)\n>  create mode 100644 a\n> + git rm a\n> rm 'a'\n> + touch a\n> + git add --intent-to-add a\n> + git status --short\n> DA a\n> + git reset -- a\n> Unstaged changes after reset:\n> A    a\n> + git status --short\n> DA a\n> ```\n>\n> Even `git reset --intent-to-add -- a` or `git checkout -- a` don't\n> seem to clear the `intent-to-add` state\n>\n> How do I reset the intent-to-add status in this case?\n>\n> Anthony\n\n\n\n-- \nDuy\n"},{"id":"366324","messageId":"CACsJy8Bov1asw+_J_fbhKqigM==xNPi8itDGkhibkYVch4pvmQ@mail.gmail.com","threadId":"50178","inReplyTo":"CACsJy8Atwp1nQbDaxYSNiDFmVmMG2h88w=dAZWU1SF6JQ18EEw@mail.gmail.com","subject":"Re: `git reset` for delete + intent-to-add doesn't reset","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2019-01-08T10:06:02Z","receivedAt":"2019-01-08T10:06:30Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Jan 8, 2019 at 4:44 PM Duy Nguyen <pclouds@gmail.com> wrote:\n>\n> On Tue, Jan 8, 2019 at 2:28 PM Anthony Sottile <asottile@umich.edu> wrote:\n> >\n> > ```\n> > git --version\n> > rm -rf t\n> > git init t\n> > cd t\n> > touch a\n> > git add a\n> > git commit -m \"add a\"\n> > git rm a\n> > touch a\n> > git add --intent-to-add a\n> > git status --short\n> > git reset -- a\n>\n> \"git reset\" without \"-- a\" does remove intent-to-add status.\n\nNo I'm wrong. But it was because I didn't follow your exact steps.\n\nThis is quite unique corner case. What happens is \"git reset\"\ninternally does \"git diff --cached\" basically to see what paths need\nto update, then reset those paths and as a side effect, intent-to-add\nstatus will be removed. But in this case, \"a\" in HEAD has empty\ncontent, exactly the same content represented by an intent-to-add\nentry. So \"git diff --cached\" decides there's no changes in \"a\", no\nneed to update it (so i-t-a status remains).\n\nThis can only happen if a file in HEAD is empty, which is quite\nunlikely. This fix could be go through the index list the second time\njust for resetting i-t-a status, but I'm not sure if it's worth doing.\n-- \nDuy\n"}]}