Skip to content

How to clone remote repo with --filter option? #713

@RoxKilly

Description

@RoxKilly

My golang application needs to list all file and folder paths in a subfolder of a git repo (a search path). I only care about the HEAD commit. I'm using Clone() first, then walking the tree from the HEAD commit.

repo, _ = git.Clone(memory.NewStorage(), nil, git.CloneOptions{URL: repoUrl, Depth: 1})
// Get commit object at HEAD
// get tree of commit object
// iterate into tree and append file names if file is within my search path

This works but the clone operation is very slow as the repo gets large and probably gives me a ton of stuff I don't need (I'm only interested in a subset of the repo tree). I noticed that the git clone docs have a --filter option that could serve my purposes. Is this option available via the go-git library? I don't see anything in the CloneOptions object

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions