{"thread":{"id":"46489","subject":"git checkout-index --all --force does not restore all files when `core.autocrlf` is set to `input`","startedAt":"2017-07-31T17:01:53Z","lastAt":"2017-07-31T17:01:53Z","messageCount":1,"participants":["Anthony Sottile"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"325302","messageId":"CA+dzEB=aC9RMOMyTGuMiboZ4OrreKQQwoOL0PXckodSfS=Xoog@mail.gmail.com","threadId":"46489","inReplyTo":null,"subject":"git checkout-index --all --force does not restore all files when `core.autocrlf` is set to `input`","fromName":"Anthony Sottile","fromEmail":"asottile@umich.edu","sentAt":"2017-07-31T17:01:47Z","receivedAt":"2017-07-31T17:01:53Z","isPatch":false,"sender":{"key":"asottile@umich.edu","avatar":"https://avatars.githubusercontent.com/u/1810591?v=4"},"body":"I'm not sure if this is a bug or the intended behaviour.\n\nHere's my minimal reproduction (using python3 to write files so I can\ncontrol line endings)\n\n```\n#!/bin/bash\nset -ex\n\nrm -rf repo\ngit init repo\ncd repo\n\ngit config --local core.autocrlf input\n\npython3 -c 'open(\"foo\", \"wb\").write(b\"1\\r\\n2\\r\\n\")'\ngit add foo\npython3 -c 'open(\"foo\", \"wb\").write(b\"3\\r\\n4\\r\\n\")'\n\ngit checkout-index --all --force\necho 'I expect this `git status` to have no modifications'\ngit status\n```\n\nHere's the output:\n\n```\n+ rm -rf repo\n+ git init repo\nInitialized empty Git repository in /tmp/foo/repo/.git/\n+ cd repo\n+ git config --local core.autocrlf input\n+ python3 -c 'open(\"foo\", \"wb\").write(b\"1\\r\\n2\\r\\n\")'\n+ git add foo\nwarning: CRLF will be replaced by LF in foo.\nThe file will have its original line endings in your working directory.\n+ python3 -c 'open(\"foo\", \"wb\").write(b\"3\\r\\n4\\r\\n\")'\n+ git checkout-index --all --force\n+ echo 'I expect this `git status` to have no modifications'\nI expect this `git status` to have no modifications\n+ git status\nOn branch master\n\nInitial commit\n\nChanges to be committed:\n  (use \"git rm --cached <file>...\" to unstage)\n\n    new file:   foo\n\nChanges not staged for commit:\n  (use \"git add <file>...\" to update what will be committed)\n  (use \"git checkout -- <file>...\" to discard changes in working directory)\n\n    modified:   foo\n\n```\n\nIn this state, `git diff` and `git diff-index` disagree as well:\n\n```\n$ git diff-index --exit-code $(git write-tree) --patch; echo $?\n1\n$ git diff --exit-code; echo $?\n0\n```\n\nI expect the plumbing command `checkout-index -af` to exactly restore\nthe disk state to the index such that `git status`, and `git\ndiff-index` both indicate there are no changes.\n\nInterestingly, `git checkout -- .` does exactly this, but it is a\nporcelain command and not suitable for scripting.  Alternatively, I'm\nlooking for an equivalent to `git checkout -- .` which uses only\nplumbing commands.\n\nThanks,\n\nAnthony\n"}]}