Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Merge method #942

Open
akamensky opened this issue Nov 27, 2023 · 3 comments
Open

Add Merge method #942

akamensky opened this issue Nov 27, 2023 · 3 comments

Comments

@akamensky
Copy link

akamensky commented Nov 27, 2023

Somehow this project has fetch and pull, but missing merge?

FWIW, pull is a fetch immediately followed by merge, so how was the pull implemented in the first place?

For my case:

I am running in-memory bare repo clone. Periodically I need to fetch updates for it and check the state of the file in repository. On bare repo this should be:

  1. git fetch origin master
  2. git merge origin/master master
  3. head -> tree -> file object -> check contents

However in the absence of merge functionality I have to:

  1. Fetch
  2. .Reference("refs/remotes/origin/HEAD") instead of just .Head()
  3. then lookup the file
@fcharlie
Copy link
Contributor

Implementing the merge feature in go-git is not an easy task; currently, there is no suitable implementation of the diff3 algorithm in Golang.

The few diff3 implementations that exist each have their own problems: nasdf/diff3 relies on github.com/sergi/go-diff just like go-git, but unfortunately, sergi/go-diff is currently erroneous. Meanwhile, epiclabs-io/diff3 is a reimplementation of node-diff3, based on the LCS algorithm; however, it is regrettable that the LGPL 3.0 licensing agreement may not be a good choice.

The maintainer of libgit2, Edward Thomson, has separated the diff3 implementation of git into the libgit2/xdiff project. This implementation has better compatibility with git and can be used with cgo or be rewritten in Golang, though this is also a significant undertaking.

In summary, implementing the merge functionality in go-git still presents some challenges; beyond the diff3 algorithm, there are many details that need to be addressed.

CC: @pjbgf

@gmax79
Copy link

gmax79 commented Feb 9, 2024

Please make it possible to create merge commit without diff3 functionality. Leave the task of filling the commit to the program code. Just need to make a method that creates a new commit based on 2 parent ones and function that will be called for the merge files

@enisdenjo
Copy link
Contributor

epiclabs-io/diff3 is now MIT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants