Handle submodule conflicts#996
Merged
Merged
Conversation
Collaborator
Contributor
Author
|
I might have more time to do this in a month (maybe before). I'd be motivated to do it though! |
lucasderraugh
approved these changes
Jun 29, 2024
Comment on lines
+358
to
+363
| // Remove superfluous "untracked" deltas for conflicting submodules | ||
| // Needed when the input _deltas looks like this: | ||
| // 1: [Conflicted] "submodule" | ||
| // 2: [Untracked] "submodule/" | ||
| // Which happens every time there's a submodule entry that's a conflict | ||
| NSMutableArray<GCDiffDelta *> *deltasToFilterOut = [NSMutableArray array]; |
Collaborator
There was a problem hiding this comment.
I haven't used submodules in a number of years so I'll play around with this a bit just to have a clear understanding myself. I'll merge it in regardless for the time being. Would be nice to cut a new release with the fixes you have here so far.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #282
I use submodules every day at work and I think GitUp is the best Git interface so this has been a regular issue for me for way too long 🤪
The basic UI I came up with looks like this:

It closely matches the current submodule diff UI, but with buttons to choose which commit should be chosen (as a side note, in a future update it would be interesting to also pull the title of each commits and display it in the diff/conflicts views as I don't know my commit SHA1s by heart).
The "sketchiest" part of this PR is probably in GCDiff.m lines 358-377. I've written an explanation in a comment right above the code to justify it, but it would be nice if the superfluous untracked diff entry was not returned by libgit2 at all, but I couldn't find any combination of diff options that could do that.
Before
Submodule conflicts weren't handled at all and any rebase that involves a submodule conflict errors out in GitUp (and the repository needs to be "Reset to Checkout..." to get a clean working directory again | Submodule conflicts can be handled with a "Choose ours" or "Choose theirs" button
Screen.Recording.2024-04-26.at.6.20.58.PM.mp4
After
Submodule conflicts can be handled with a "Choose ours" or "Choose theirs" button
Screen.Recording.2024-04-26.at.6.23.39.PM.mp4
Here's the repository I used for my tests:
test-repo-submodules.zip
Once #989 is merged, I could use it as a base to write a unit test that checks that submodule conflicts are well handled.
I AGREE TO THE GITUP CONTRIBUTOR LICENSE AGREEMENT