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

Handle submodule conflicts #996

Merged
merged 1 commit into from
Jun 29, 2024

Conversation

lapfelix
Copy link
Contributor

@lapfelix lapfelix commented Apr 26, 2024

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:
image

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

@lucasderraugh
Copy link
Collaborator

@lapfelix I'll come back on this one. You mention at the end that you'd use #989 as a base for unit tests on this. Would you still have interest in this? I understand if not, just want to know whether I should review this as is.

@lapfelix
Copy link
Contributor Author

I might have more time to do this in a month (maybe before). I'd be motivated to do it though!

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];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@lucasderraugh lucasderraugh merged commit b7a1da7 into git-up:master Jun 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

GitUp does not handle submodule conflicts
2 participants