Fix win32 checkout test

Fix the checkout tests that were broken on Windows.

I ended up moving a bunch of helper functions into a separate file to clean this up, and only after that realized that the real problem was that a checkout using `GIT_CHECKOUT_REMOVE_UNTRACKED` was removing the `.gitattributes` file that was supposed to prevent CRLF expansion on Windows.

Anyhow, this fixes the problem.