Subject: Re: [PATCH 3/3] stash: restore untracked files AFTER restoring tracked files

From: Junio C Hamano <[email-masked]>
Date: Wed, 08 Sep 2021 09:30:44 -0700

"Elijah Newren via GitGitGadget" <[email-masked]> writes:

> From: Elijah Newren <[email-masked]>
>
> If a user deletes a file and places a directory of untracked files
> there, then stashes all these changes, the untracked directory of files
> cannot be restored until after the corresponding file in the way is
> removed.  So, restore changes to tracked files before restoring
> untracked files.
>
> There is no similar problem to worry about in the opposite directory,

direction, I think.

If a user deletes a directory with tracked files in it and places an
untracked file at the path the directory used to be, and then stash
all these changes, that would be the opposite direction, I would
presume?  The untracked file would be restorable only after applying
the removal of the tracked files that occupied the directory.

Which would be fine if we apply the changes to the tracked ones first.

OK.

After creating a stash, we clear the working tree.  How do we do
that exactly, and would we have a similar problem there?  We need to
first remove the untracked file that currently occupies where the
directory used to be in HEAD, and then create the directory and
resurrect the tracked files in the directory from HEAD, in my
modified example above.  In the file-becomes-directory scenario, is
the story the same?

Thanks.