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

Already on GitHub? Sign in to your account

Add implementation and test for discover_path #883

Merged
merged 1 commit into from
Nov 19, 2022

Conversation

mikayla-maki
Copy link
Contributor

@mikayla-maki mikayla-maki commented Sep 21, 2022

Hi y'all,

We're looking to use this library to build the git integration in our code editor (zed.dev). In order to do so, we wanted to cache the Repository::open_ext() call based on the repository path. But git2-rs's implementation of Repository::discover() automatically opens the repository for us, making it impossible to cache :(

I've added a Repository::discover_path() function that more closely matches the libgit2 git_repository_discover() call. I had to add an extra allocation to convert the git buffer into a PathBuf and would appreciate feedback on if there's a way to avoid the allocation.

I also added 2 tests, one for a successful discovery and one for an unsuccessful one that uses ceiling_dirs.

Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ehuss ehuss merged commit c93d29b into rust-lang:master Nov 19, 2022
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.

2 participants