Merge pull request #3542 from libgit2/cmn/reset-dir-file reset: perform the checkout before moving HEAD or the index