Skip to content

Implement ordered traversal and traversal depth #614

@oknozor

Description

@oknozor

Summary 💡

As mentioned here the git-traverse crate only support non-ordered breadthfirst traversal.
https://github.com/Byron/gitoxide/blob/ff9e1571b558475e727dc6ba11dab24ef15fb6f4/git-repository/src/object/tree/traverse.rs#L47-L48

Motivation 🔦

I am building a git platform using gitoxide.

The tree explorer you can see in the screenshot below use the current breadth-first search traversal.

The current implementation works fine but needs to traverse the entire tree from root each time we load a page. An alternative would be to load the tree in order with a given depth to get only what needs to be rendered.

Example

. // root
├── one
│   ├── two // depth 1
│   │   └── blob // depth 2
│   └── tree // depth 1
│       ├── blob // depth 2
│       ├── blob // .. 
│       ├── blob // ..

And this is the real life use case :
screenshot-2022-11-20T21:58:21

I have no idea if this is doable, I will try to implement it if you are ok with the idea.
Otherwise I will just cache everything :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions