Subject: Re: git probably bug

From: Junio C Hamano <[email-masked]>
Date: Thu, 26 Feb 2015 13:36:11 -0800

Виталий Бормотов  <[email-masked]> writes:

> When checking out into some different
> state, if there is no permissions to unlink files (if some files in
> the current state doesn't exist in the new) warnings are outputing,
> but then git says that checking out is successful, shows that we are
> in the new state and the non-unlinked files are marked as
> untracked.

This is done by reasonably old part of the codebase, and I think it
is exactly working as designed.  Unlinking of an existing path in
the filesystem is done for one of the two reasons:

 - The old tree has the path, the new tree does not.

 - The old tree has the path, the new tree has it but with a
   different content.

In both cases, we first attempt to unlink (and warn if we cannot)
and then attempt to create the path with the new contents in the
latter case (and die if we cannot).

The checkout itself succeeds, because having untracked cruft in your
working tree is not an error, but warnings are given to let you know
that you may want to remove them after fixing the screwy permission
problem yourself.