libgit2 / libgit2sharp

Git + .NET = ❤
http://libgit2.github.com
MIT License
3.17k stars 886 forks source link

git lfs is not supported #1973

Open tapika opened 2 years ago

tapika commented 2 years ago

Commands.Stage & repo.Commit does not preserve LFS files at all, even if LFS is enabled.

Also if you try to read from git history using API like:

Blob blob = repo0.Lookup<Blob>(change.Oid);
using (Stream stream = blob.GetContentStream());
...

Instead of file - you will read pointer file instead - https://github.com/git-lfs/git-lfs/blob/main/docs/spec.md

text file.

Would be nice if LFS would be supported in libgit2sharp library.

dsynclabsllc commented 1 year ago

I concur. This is very disappointing. This should just work with some easily configured control.

lucianm commented 2 months ago

Although LibGit2Sharp provides the means of easily supporting a feature like LFS which is using filters, as someone not really familiar with the LibGit2Sharp code and architecture, I cannot really see where the (possibly many) places in the code would be to register such a LFS filter. However, as I'm interested in a particular LibGit2Sharp-based application becoming LFS-aware, that's a different story, as it has a clear entry point for running a command or workflow, and then some sort of shutdown. I'm talking about git-tfs, which I managed to make LFS-aware with the help of the discussions and code found in #1236 . I added such a filter I found in a gist linked in the mentioned issue to my git-tfs fork, thankfully the entire actual LFS support is implemented in the filter, which could actually be contributed to LibGit2Sharp instead of git-tfs, as it's generic and other applications might make use of it if needed, as well, it's like I said, just a matter of registering the filter at startup and de-registering it on shutting down.

That implementation works well for me from the command line under Windows 10, I'm only having some issues when I use the same commands in git-extensions, but that might be another story. Git-LFS is automatically being installed by the filter due to the git lfs command itself (which it is spawning) whenever .gitattributes entries would trigger the filter (it does so for example when I'm cloning a testing branch from TFS, in which I checked in a .gitattributes file tracking some binary files in LFS as the very first chnageset, followed by others containing such binaries, and it also does the correct cleaning or smudging when git-tfs would synchronize between TFS changesets and git commits.

What do LibGit2Sharp developers think of it, can the filter be made available to a broader program base by including it? Is there an "easy" way to provide this filter "readily" registered for any application using LibGit2Sharp transparently (which I do not really think)?