{"thread":{"id":"20014","subject":"unexpected empty commit after checkout with uncommitted index","startedAt":"2009-07-03T11:28:27Z","lastAt":"2009-07-03T11:28:27Z","messageCount":1,"participants":["Chris Johnsen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"117414","messageId":"B98E6930-01E8-4A14-9C09-CC2BACC3389C@pobox.com","threadId":"20014","inReplyTo":null,"subject":"unexpected empty commit after checkout with uncommitted index","fromName":"Chris Johnsen","fromEmail":"chris_johnsen@pobox.com","sentAt":"2009-07-03T11:28:27Z","receivedAt":"2009-07-03T11:28:27Z","isPatch":false,"sender":{"key":"chris_johnsen@pobox.com","avatar":"https://avatars.githubusercontent.com/u/107071?v=4"},"body":"The following test script fails after 83ae209 (checkout branch: prime  \ncache-tree fully, 2009-04-20).\n\n-- \nChris\n\n#!/usr/bin/env dash\nabort() {\n     printf \"$@\"\n     exit 128\n}\nfailed=0\nfail() {\n     failed=1\n     printf \"$@\"\n}\n\nset -e\n\nGIT=\"${1:-git}\"\ncase \"$GIT\" in\n./*|../*) GIT=\"$PWD/$GIT\"\nesac\ntype \"$GIT\" > /dev/null ||\n     abort 'bad git command?: %s\\n' \"$GIT\"\n\ntn=checkout-with-changed-index\ntd=\"$(mktemp -d -t \"$tn\")\"\nif test -z \"$td\"; then\n     td=\"/tmp/$tn\"\n     mkdir \"$td\" ||\n         abort 'unable to create test dir: %s\\n' \"$td\"\n     test -d \"$td\"/.git &&\n         abort '.git already exists in test dir: %s\\n' \"$td\"\nfi\ntrap 'rm -rf \"$td\"' 0\n\ncd \"$td\"\n\"$GIT\" --version\n\"$GIT\" init\necho foo > foo\necho bar > bar\n\"$GIT\" add foo bar\n\"$GIT\" commit -m 'add foo, bar'\necho BAR > bar\necho baz > baz\n\"$GIT\" rm foo\n\"$GIT\" add bar baz\n\"$GIT\" checkout -b new\n\"$GIT\" commit -m 'rm foo, change bar, add baz'\n\n# After 83ae209 the commit on \"new\" (or even a detached HEAD if\n# we use \"HEAD@{0}\" instead of \"-b new\") appears to be an empty\n# commit. The same thing happens whether the changes (add new, rm\n# existing, add edited) are done in a group, as above, or\n# individually.  Both before and after the commit, [git status]\n# seems to show that the changes are properly staged, but they\n# never make it into the committed tree. [git reset] and then\n# [git add --all] resolves the strange state and allows the\n# expected commit to take place.\n\ntest -z \"$(\"$GIT\" ls-tree HEAD foo)\" ||\n     fail '*** foo was not removed\\n'\ntest \"$(\"$GIT\" cat-file blob HEAD:bar)\" = \"BAR\" ||\n     fail '*** bar was not changed\\n'\ntest \"$(\"$GIT\" cat-file blob HEAD:baz)\" = \"baz\" ||\n     fail '*** baz was not added\\n'\nexit $failed\n"}]}