Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to forced checkout and untracked files #4260

Merged
merged 4 commits into from Jun 11, 2017

Commits on Apr 10, 2017

  1. Configuration menu
    Copy the full SHA
    78b8f03 View commit details
    Browse the repository at this point in the history

Commits on Jun 10, 2017

  1. checkout: do not delete directories with untracked entries

    If the `GIT_CHECKOUT_FORCE` flag is given to any of the `git_checkout`
    invocations, we remove files which were previously staged. But while
    doing so, we unfortunately also remove unstaged files in a directory
    which contains at least one staged file, resulting in potential data
    loss.
    
    This commit adds two tests to verify behavior.
    pks-t authored and ethomson committed Jun 10, 2017
    Configuration menu
    Copy the full SHA
    0ef405b View commit details
    Browse the repository at this point in the history
  2. checkout: cope with untracked files in directory deletion

    When deleting a directory during checkout, do not simply delete the
    directory, since there may be untracked files.  Instead, go into
    the iterator and examine each file.
    
    In the original code (the code with the faulty assumption), we look to
    see if there's an index entry beneath the directory that we want to
    remove.   Eg, it looks to see if we have a workdir entry foo and an
    index entry foo/bar.txt. If this is not the case, then the working
    directory must have precious files in that directory. This part is okay.
    The part that's not okay is if there is an index entry foo/bar.txt. It
    just blows away the whole damned directory.
    
    That's not cool.
    
    Instead, by simply pushing the directory itself onto the stack and
    iterating each entry, we will deal with the files one by one - whether
    they're in the index (and can be force removed) or not (and are
    precious).
    
    The original code was a bad optimization, assuming that we didn't need
    to git_iterator_advance_into if there was any index entry in the folder.
    That's wrong - we could have optimized this iff all folder entries are
    in the index.
    
    Instead, we need to simply dig into the directory and analyze its
    entries.
    ethomson committed Jun 10, 2017
    Configuration menu
    Copy the full SHA
    83989d7 View commit details
    Browse the repository at this point in the history
  3. git_futils_rmdir: only allow EBUSY when asked

    Only ignore `EBUSY` from `rmdir` when the `GIT_RMDIR_SKIP_NONEMPTY` bit
    is set.
    ethomson committed Jun 10, 2017
    Configuration menu
    Copy the full SHA
    4a0df57 View commit details
    Browse the repository at this point in the history