update-index: stat updated files earlier
commiteb12dd0c764d2b71bebd5ffffb7379a3835253ae
authorJeff King <peff@peff.net>
Mon, 14 May 2018 15:00:56 +0000 (14 11:00 -0400)
committerJeff King <peff@peff.net>
Tue, 22 May 2018 03:50:11 +0000 (21 23:50 -0400)
treef3bf6c5ab43cc098fd2e026b336a300dc07f7a93
parent641084b618ddbe099f0992161988c3e479ae848b
update-index: stat updated files earlier

In the update_one(), we check verify_path() on the proposed
path before doing anything else. In preparation for having
verify_path() look at the file mode, let's stat the file
earlier, so we can check the mode accurately.

This is made a bit trickier by the fact that this function
only does an lstat in a few code paths (the ones that flow
down through process_path()). So we can speculatively do the
lstat() here and pass the results down, and just use a dummy
mode for cases where we won't actually be updating the index
from the filesystem.

Signed-off-by: Jeff King <peff@peff.net>
builtin/update-index.c