docs: Recommend to use '* merge=mergiraf' #384
No reviewers
Labels
No labels
Compat/Breaking
Kind
Bad merge
Kind
Bug
Kind
Documentation
Kind
Enhancement
Kind
Feature
Kind
New language
Kind
Security
Kind
Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: mergiraf/mergiraf#384
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "wetneb/mergiraf:simplify_gitattributes"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #57. Also closes #244.
I'm trying out this setup myself to see if I notice any issue with it. I think the fallback to line-based merge is quick enough that this doesn't add too much overhead for file types we don't support.
By the way, maybe it would be possible to incorporate the line-based-fallback logic into Git itself? So we would return a special exit code if we know we can't handle the given language, and Git would in turn run
git merge-file
internally, which might be faster than us shelling out. I think this functionality would be helpful even outside Mergiraf (in fact I believe the issue would've already been implemented if custom merge drivers were more prevalent).In fact, doesn't the error code thing basically exist already? Quoting "Defining a custom merge driver":
So Git could perform the fallback on exit code >128
That sounds like a good idea! But at the moment (git v2.47.2), it seems that git simply aborts the entire operation if mergiraf returns code 129. If Git was to change this in a later version, then we'd need to know the Git version to know if we can allow ourselves to fail, or if we should handle the fallback on our side. So that would probably mean running
git --version
to find out?But at that rate we might as well rungit merge-file
directly, perhaps…One question I have is whether we should rather use our own line-based merging (which doesn't require starting a new process) or git's own (which might better respect git's configuration, and is likely more optimized than the diffy implementation).
cb8d05b3a0
to01c90a891d
WIP: docs: Recommend to use '* merge=mergiraf'to docs: Recommend to use '* merge=mergiraf'I've been trying this out on various codebases and didn't notice anything particular, beyond the warning that I disabled above, so this seems good to go as far as I am concerned.
@ -49,15 +49,20 @@ $ git config --global core.attributesfile ~/.gitattributes
Then, you also need to specify for which sorts of files this merge driver should be used. Add the following lines to your global `~/.gitattributes` file:
this line probably needs to be updated as well
I wanted to suggest gix as another option (
gix-merge
in particular), but it operates on a whole repo, so using it would be more complicated than just passing 3 strings. Digging into the source code a bit though, it seems to boil down to the sameimara-diff
-based merge we use: https://docs.rs/gix-merge/0.5.1/src/gix_merge/blob/builtin_driver/text/function.rs.html#28. So I guess that's another point for the first option.Actually, I wonder whether we could just hook into these internals, and get rid of diffy-imara completely
Ah nice! Last time I looked I hadn't been able to find this sort of functionality there, I don't know if it's because it wasn't there yet or I didn't look closely enough.
Switching sounds good to me in principle, but looking at the dependencies of
gix-merge
, it seems that it's far from self-contained. It looks likediffy-imara
remains more lightweight and quite fitting for us, no?I guess the dependencies are there because of all the Git-related logic, but we kind of want that if we want to respect Git config and such, no?
Otherwise we could maybe persuade them to extract the pure string merging algorithm into a separate crate we could then take a dependency on. But this would be pretty much what we have already with diffy-imara, yeah (aside from the latter being much worse maintained by yours truly 😅)
Perhaps… I am not sure to what extent their implementation really does!