Skip to content

Clean untracked files from working directory #253

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

jamill
Copy link
Member

@jamill jamill commented Nov 26, 2012

Current checkout tests rely on Reset to update the tracked and untracked files in a working directory. However, proper behavior is for Reset to only modify the tracked files. This PR:

  1. Implements functionality to remove untracked files from the working directory
  2. Updates the checkout tests to clean the working directory

Some other thoughts:

  • I currently have the CleanWorkingDirectory implemented on the Index class, but I could see this exposed off of the Repository class as well, which is where some other methods that impact both the index and the working directory exist (e.g. Reset).
  • There is not currently an explicit git clean function exposed in libgit2 - I implemented this functionality through calling git_checkout_index with a parameter indicating that it should remove untracked files. This means that not all the core git clean options are supported, such as removing ignored files as well. If there are other cases where cleaning with git_checkout_index does not behave as we want here, please bring them up as well.

This implements git clean and exposes the ability to remove untracked files from the working directory.
If / when git clean functionality is exposed directly by libgit2, we can update this to use that entry point.
Currently, we call git_checkout_index with a flags indicating that untracked entries should be removed. This does
not support other flags exposed by core Git, such as removing ignored files.
Checkout tests were originally written under the assumption that git
reset would remove untracked files (reset, as implemented in LibGit2Sharp,
originally mistakenly removed untracked files). This updates the tests
to reset and clean the working directory.
@jamill
Copy link
Member Author

jamill commented Dec 4, 2012

Included with PR #260.

@jamill jamill closed this Dec 4, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant