Skip to content

Improve conflict resolution#6267

Merged
dkurepa merged 6 commits into
dotnet:mainfrom
dkurepa:dkurepa/ImproveConflictResolution
May 14, 2026
Merged

Improve conflict resolution#6267
dkurepa merged 6 commits into
dotnet:mainfrom
dkurepa:dkurepa/ImproveConflictResolution

Conversation

@dkurepa
Copy link
Copy Markdown
Member

@dkurepa dkurepa commented May 7, 2026

#6265

It looks like some git weirdness is happening in the vstest flows.
We're rewinding previous flows, and by doing so the work branch is "losing" some changes outside of the src/repo we're flowing to, as expected. But when we try to rebase the workbranch on top of the origin branch, these files that we're lost on the workbranch conflict with the ones in the target branch.
Not sure what is causing this but it's easy enough to fix.

I'm also failing to replicate in a test.
I think it might have to do something with the unsafe flow? And git is not able to figure it out.
In any case this fixes the issue

Copilot AI review requested due to automatic review settings May 7, 2026 12:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR targets codeflow reliability in the Virtual Mono Repo (VMR) forward-flow path by improving how git conflicts are auto-resolved—especially in scenarios involving recreated/rewound flows where conflict shapes can include delete/modify cases and conflicts outside the mapped src/<repo> folder.

Changes:

  • Auto-resolve forward-flow conflicts that occur outside the mapped repo folder by preferring one side.
  • Enhance LocalGitClient.ResolveConflict to resolve delete/modify conflicts by inspecting git status --porcelain and using git rm/git add when appropriate.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/ForwardFlowConflictResolver.cs Adds a rule to auto-resolve conflicts outside the flowed repo folder and refactors repo-source-path reuse.
src/Microsoft.DotNet.Darc/DarcLib/LocalGitClient.cs Reworks conflict resolution to handle delete/modify by interpreting porcelain status and choosing rm/add/checkout accordingly.

Comment thread src/Microsoft.DotNet.Darc/DarcLib/LocalGitClient.cs
Comment on lines +633 to +637
?? throw new Exception($"No status entry found for {file} in {repoPath} - is it actually conflicted?");

if (line.Length < 2)
{
throw new Exception($"Unexpected git status output for {file} in {repoPath}: '{line}'");
@dkurepa
Copy link
Copy Markdown
Member Author

dkurepa commented May 8, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

result.ThrowIfFailed($"Failed to stage resolved conflict in {file} in {repoPath}");
// Map each unmerged status code to (ourBlob, theirBlob) - whether each
// side contributed a blob to the index.
var (ourBlob, theirBlob) = code switch
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's kinda hard to validate this and there's no tests to support this. Would it be possible to make AI generate real changes to get these combinations and verify we get the right outcomes?

Could be a follow-up if you're sure about this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah I think this part wouldn't be hard to validate, should be pretty easy to make these conflicts in a small git repo

Comment on lines +325 to +329
var updateIndex = await _processManager.ExecuteGit(
_repoPath,
["update-index", "--index-info"],
standardInput: indexInfo.ToString());
updateIndex.ThrowIfFailed("git update-index --index-info failed");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Interesting - this is what I was thinking of doing even in resolve-conflict where we could "materialize" a conflict of a specific kind if we know there should be one. But then we were able to let the rebase take care of this.

@dkurepa dkurepa merged commit 5f0682f into dotnet:main May 14, 2026
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants