gitlib icon indicating copy to clipboard operation
gitlib copied to clipboard

Frontend API for fetch, clone, merge, pull, push.

Open TravisWhitaker opened this issue 7 years ago • 3 comments

Hi John, thanks for your work on these packages!

I'm curious if you have any thoughts on what higher-level APIs for fetch, clone, merge, pull, and push operations might look like. As it stands, it looks like there's a bit of inconsistency among the backends with respect to how these operations are performed. As far as I can tell, this is how these operations are supported currently:

  • Fetch: Provided by Git.Libgit2.lgRemoteFetch. It looks like MonadGit used to have a remoteFetch method.
  • Clone: Provided by lgRemoteFetch followed by Git.Working.checkoutFiles. However, Bindings.Libgit2.Clone is also provided; it's not clear what advantages using libgit2's convenience function for this might be.
  • Merge: At a low level, the caller can implement whatever "merge" strategy they want by directly manipulating blobs and trees, and creating a commit with multiple parents. However, it would be useful to provide an API for writing conflicts to the index for compatibility with the git command line tool. It doesn't look like the readIndex or writeIndex methods are implemented anywhere. libgit2 provides a handy set of merge utility functions that'd be useful in the frontend API as well.
  • Pull: Provided by lgRemoteFetch plus merging at a low-level with blobs and trees.
  • Push: We have Git.Commit.Push.pushCommit, but something in Git.Libgit2 that takes advantage of libgit2's (likely more efficient?) push functionality would be handy.

Am I missing anything obvious/more convenient here?

A potential issue with introducing a frontend API for these operations is the difference in functionality among existing and future backends. Perhaps MonadGit could be broken into smaller classes, allowing backends to implement specific subsets of the frontend API capabilities.

TravisWhitaker avatar Jun 29 '18 22:06 TravisWhitaker

Some nice ideas, and I don't see that you've missed much. Do you want to take over maintenance of gitlib-libgit2 perhaps?

jwiegley avatar Jun 30 '18 07:06 jwiegley

I'll take a crack at these as time allows, and if you're looking for a (co-)maintainer I'd be happy to help.

TravisWhitaker avatar Jul 03 '18 19:07 TravisWhitaker

@TravisWhitaker Yes, someone to help move things forward would be fantastic. I haven't had much time for gitlib lately, but I'd be more than happy to assist.

jwiegley avatar Jul 03 '18 19:07 jwiegley