{{ message }}
Repository navigation
Fix over-zealous deletions with certain checkout options - #7401
Open
Caleb-T-Owens wants to merge 2 commits into
Open
Caleb-T-Owens wants to merge 2 commits into
Caleb-T-Owens wants to merge 2 commits into
Conversation
Certain force checkout scenarios are removing whole directories when they should be removing just some of the contents of the directory. A key example is when a directory contains both ignored and untracked files. If an operation to checkout head with the options to remove untracked is set, the whole directory will be removed, destorying the ignored files.
This change affects checkouts that want to remove either untracked files or ignored files, but not both with a particular checkout. Previously, these directories were let to fall through, which resulted in them getting dropped. This change adds an extra condition for a folder to be considered for checkout descent if it is not git ignored, is removable, but isn't empty.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

At GitButler, we've run into an issue when doing a
checkout_headwithremove_untracked(true)andremove_ignored(false).It seems like the checkout skips over these directories that contain no tracked files which results in their deletion, resulting in data loss.
This PR was a little exploration into the problem, but I'm always very nervous about making changes with C code, so please take this with a pinch of salt.
The solution implemented is to have an extra check that considers a folder for descent if it is not git ignored, is removable, but isn't empty.
Thanks for your time.