src-d / go-git

Project has been moved to: https://github.com/go-git/go-git
https://github.com/go-git/go-git
Apache License 2.0
4.9k stars 540 forks source link

Open() with a memfs worktree #1178

Open abh opened 5 years ago

abh commented 5 years ago

In https://godoc.org/gopkg.in/src-d/go-git.v4#example-Clone there's an example of cloning a repository and using memfs as the worktree.

Is this possible with an existing bare git repository on disk, too?

Alternatively, if I have a bare repository opened already (*git.Repository), can I set/reset the Worktree to a fresh memfs?

belak commented 5 years ago

Yes, this is possible. I use this in go-gitdir to load files stored as a part of a server (so I don't want worktrees around)

https://github.com/belak/go-gitdir/blob/master/internal/git/repository.go