Coder Social home page Coder Social logo

Merge conflicts about neogit HOT 8 CLOSED

neogitorg avatar neogitorg commented on July 20, 2024
Merge conflicts

from neogit.

Comments (8)

TimUntersberger avatar TimUntersberger commented on July 20, 2024 5

@Shatur95 I would also like more of a buffer oriented style like in vscode intead of the common 3 split diff thing.

from neogit.

Shatur avatar Shatur commented on July 20, 2024 1

What about VSCode-like approach?
изображение
Very handy and easy to use.

There is already a plugin in Vimscript for it.

from neogit.

TimUntersberger avatar TimUntersberger commented on July 20, 2024

Supporting a view similiar to #57 for merge conflicts would also be good.

from neogit.

Odie avatar Odie commented on July 20, 2024

This might be enough info to attempt implementing a merge feature.

When trying to merge branches and there appears to be a conflict, there seems to at least 3 ways to detect this:

  • git merge <branch> exit status will be 1. Some error text is also sent via stdin.
  • git log --merge --oneline will show the conflicting commits. It'll error out if it's not in the middle of a merge.
  • git status --porcelain will return items marked with "UU" indicating the file is unmerged.

After determining we're in the middle of a merge, we can use git diff show a list of conflicting files & hunks.

For example:

diff --cc file1.txt
index f201d7f,2a46cea..0000000
--- a/file1.txt
+++ b/file1.txt
@@@ -1,7 -1,5 +1,12 @@@
++<<<<<<< HEAD
 +Changes are
 +an unavoidable
 +part of
 +life
++=======
+ Conflicts
+ Happens
++>>>>>>> develop

  Hello
  World!

This gives us a definitive list of files and hunks to visit to resolve the merge conflict. It shouldn't be too difficult to implement a "jump to next conflict" feature. Maybe this info can be presented somewhat like the status buffer to keep a consistent look & feel?

To bring up the diff interface, we need the contents of the two versions of the file where the conflict happened:

  • Ours/local version
    Take the on-disk/working-tree version and cleanup to strip out the conflict markers & text. This should bring across any merged content that did not produce any conflict

  • Theirs/remote version
    The file diff header index f201d7f,2a46cea..0000000 contains enough info to grab the contents of the file that produced the conflict. In this case, we can run git show 2a46cea file1.txt.

from neogit.

TimUntersberger avatar TimUntersberger commented on July 20, 2024

@Odie nice work!

I guess now we really just have to think about the ui/ux stuff. What are you expectations for something like this?

Maybe this info can be presented somewhat like the status buffer to keep a consistent look & feel?

I think something like this would be cool! I don't know how we would support expanding the viewed code upwards/downwards though.

from neogit.

Odie avatar Odie commented on July 20, 2024

I think something like this would be cool! I don't know how we would support expanding the viewed code upwards/downwards though.

Maybe it can be a 3 pane operation. One pane can be like the status view, where the purpose is to:

  1. Get an overview of remaining conflicting hunks
  2. Select and navigate to the conflicted hunk/lines (especially useful for jumping to a specific file)

The other two panes would be to display the file diffs when the conflicted lines are navigated to. A hot key would be available to jump to the next conflict. It’d take the user to another file if there are no more conflicts in the current file.

from neogit.

Odie avatar Odie commented on July 20, 2024

That sounds good too. Just thought this merge feature initially came from someone asking for a 2 way diffing merge view. :)

from neogit.

ten3roberts avatar ten3roberts commented on July 20, 2024

Diffview now has support for merge conflicts similar to the VSCode approach, so from Neogit's side, all which remains to do is reporting of the merge failure rather than "Git command failed press $ ...", as well as showing then inline conflict diff like with modified files

from neogit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.