Fix IsConflictResolved check for submodule#1356
Merged
love-linger merged 1 commit intoMay 24, 2025
Merged
Conversation
Collaborator
|
I'd like to change the modifications as follows First, use different commands for text-files and submodules public class IsConflictResolved : Command
{
public IsConflictResolved(string repo, Models.Change change, bool isSubmodule)
{
_change = change;
_isSubmodule = isSubmodule;
WorkingDirectory = repo;
Context = repo;
}
public bool Result()
{
if (!_isSubmodule)
{
var opt = new Models.DiffOption(_change, true);
Args = $"diff -a --ignore-cr-at-eol --check {opt}";
return ReadToEnd().IsSuccess;
}
Args = $"--no-optional-locks status --porcelain=v2 -- \"{_change.Path}\"";
var rs = ReadToEnd();
return rs.IsSuccess && rs.StdOut.StartsWith('u');
}
private readonly Models.Change _change = null;
private readonly bool _isSubmodule = false;
}The modify the constructor of var isSubmodule = repo.Submodules.Find(x => x.Path.Equals(change.Path, StringComparison.Ordinal)) != null;
IsResolved = new Commands.IsConflictResolved(repo.FullPath, change, isSubmodule).Result(); |
A submodule conflict is not resolved until it's Staged.
d928e69 to
6665a6b
Compare
Contributor
Author
|
@love-linger I rewrote my commit, the new solution is much simpler (if the file is a submodule entry we just bypass |
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.
Improved IsConflicResolved check, to work correctly for submodule conflicts.
Added an extra (lock-free) call to git-status with--porcelain=v2which makes it easy to check that:The file is still "unmerged".The file is a submodule (or not).If the file is a submodule, we always
returnregard the conflict as unresolved (while Unstaged), since we can't use text-diff check on submodules and the conflict is not resolved until it's Staged.false(while it's unmerged)