NeogitOrg / neogit

An interactive and powerful Git interface for Neovim, inspired by Magit
MIT License
3.86k stars 227 forks source link

Discard Conflicted Files #1189

Closed gollth closed 6 months ago

gollth commented 6 months ago

Hi @CKolkey, me again (=

AFAIK so far there is no option to discard files which are in conflict. I really liked the Magit way of handling this, that is asking the user to use "ours" or "theirs", so I recreated that behavior in Neogit.

Neogit-discard-conflict.webm

Notes

  1. This does not work yet rebased on master, because of #1176. Best is not to merge before this is fixed
  2. This does only for for entire files up to now. Discarding conflicted hunks does not work. I want to try this next, but have to understand the "patching" logic for hunks. Ideas/explanations welcome
CKolkey commented 6 months ago

Nice! This is great - something I've wanted to add for a while, but I've been holding off on adding stuff to the status buffer until https://github.com/NeogitOrg/neogit/pull/1161 is done. Which... is close!

Anyways, for the hunk stuff, it looks like Magit uses smerge under the hood: https://github.com/emacs-mirror/emacs/blob/master/lisp/vc/smerge-mode.el#L411

... So maybe the hunk stuff can be in a follow-up PR.

gollth commented 6 months ago

Cool thanks for the hint, will definitely take a look at smerge. BTW any idea why the tests in the CI are failing? Locally that works for me. It looks like finding the line "Both modified" does not work in the status UI. Is this somehow different in the CI? :thinking:

CKolkey commented 6 months ago

No... the CI situation is a bit lame in that respect. And since it feels a lot like work, I haven't dug into it much, haha. There's a PR where I made a whole test harness in ruby, which is (imo) much nicer than the lua framework, and doesnt have async related issues, but... the rpc stuff just hangs on GHA. Some day

I'll just bench test the feature, then port it to the new status buffer

CKolkey commented 6 months ago

This is awesome. Thank you :)