Fix trailing whitespaces
Fix diff crash when last item is untracked dir

When the last item in a diff was an untracked directory that only
contained ignored items, the loop to scan the contents would run
off the end of the iterator and dereference a NULL pointer.  This
includes a test that reproduces the problem and a fix.
Remove old symlinks before updating

Unlike blob updates, symlink updates cannot be done "in place"
writing over an old symlink.  This means that in checkout when we
realize that we can safely update a symlink, we still need to
remove the old one before writing the new.
Fix checkout of submodules with no .gitmodules

It is possible for there to be a submodule in a repository with
no .gitmodules file (for example, if the user forgot to commit
the .gitmodules file).  In this case, core Git will just create
an empty directory as a placeholder for the submodule but
otherwise ignore it.  We were generating an error and stopping
the checkout.  This makes our behavior match that of core git.
Improve robustness of diff rename detection

Under some strange circumstances, diffs can end up listing files
that we can't actually open successfully.  Instead of aborting
the git_diff_find_similar, this makes it so that those files just
won't be considered as valid rename/copy targets instead.
Use GIT_IDXENTRY_STAGE macro

Since I added the GIT_IDXENTRY_STAGE macro to extract the stage
from a git_index_entry, we probably don't need an internal inline
function to do the same thing.
Merge pull request #1578 from nulltoken/fix/whitespaces

Fix trailing whitespaces
Merge pull request #1588 from arrbee/fixes-for-checkout-and-diff

Bug fixes for checkout and diff