checkout: use cache when possible to determine if workdir item is dirty

If the on-disk file has been staged (it's stat data matches the stat data
in the cache) then we need not hash the file to determine whether it
differs from the checkout target; instead we can simply use the oid in
the index.

This prevents recomputing a file's hash unnecessarily, prevents loading
the file (when filtering) and prevents edge cases where filters suggest
that a file is dirty immediately after git writes the file.
Merge pull request #1477 from ethomson/checkout_modified_use_cache

checkout: use cache when possible to determine if workdir item is dirty