]> git.ipfire.org Git - thirdparty/git.git/commit
unpack-trees: handle lstat failure for existing file
authorJonathan Nieder <jrnieder@gmail.com>
Thu, 13 Jan 2011 02:28:09 +0000 (20:28 -0600)
committerJunio C Hamano <gitster@pobox.com>
Thu, 13 Jan 2011 19:26:09 +0000 (11:26 -0800)
commita93e530184b3f7ae9d9bfb0e569734687f8d1c0b
tree21ebaba78fd780dabd8bcc2357499d40bd11adfb
parent92fda79ed048d2d37e760e7a1b6055b2fc801ee3
unpack-trees: handle lstat failure for existing file

When check_leading_path notices a file in the way of a new entry to be
checked out, verify_absent uses (1) the mode to determine whether it
is a directory (2) the rest of the stat information to check if this
is actually an old entry, disguised by a change in filename (e.g.,
README -> Readme) that is significant to git but insignificant to the
underlying filesystem.  If lstat fails, these checks are performed
with an uninitialied stat structure, producing essentially random
results.

Better to just error out when lstat fails.

The easiest way to reproduce this is to remove a file after the
check_leading_path call and before the lstat in verify_absent.  An
lstat failure other than ENOENT in check_leading_path would also
trigger the same code path.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
unpack-trees.c