Self-referential repo + tree
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 2.1k
- Forks
- 450
- Avg merge
- 11m
- Merged PRs (30d)
- 1
Description
I've found that I often need to store a Repository and a Tree<'repo> that borrows from it. Unfortunately, this creates unsafe self-referential structs.
It would be helpful if this crate provided a safe abstraction for repo + tree together, e.g.
let repo = git2::Repository::open()?;
/// makes RepositoryWithTree
let repo = repo.with_tree(|repo| {
repo.find_commit(head)?.tree()
});
*repo // Derefs to Repository
repo.tree(); // returns borrowed Tree
Alternatively, there's owning-ref that has OwningHandle trait. It would require git2 types to implement its traits.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Repository and Tree APIs and the proposed with_tree entry point; compare the owning_ref OwningHandle requirements mentioned in the issue. Define the safe ownership and borrowing behavior, then validate it with focused tests; done means callers can keep a Repository and borrowed Tree together without unsafe self-referential structs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100