libgit2 / libgit2/libgit2sharp
Two conflicts instead of one for renamed file
Open
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 3.5k
- Forks
- 925
- PR merge metrics
- No merged PRs in 30d
Description
Reproduction steps
- Checkout commit https://github.com/ydanila/test_git from https://github.com/ydanila/test_git
- Renamed README.md to README2.md and commit (will be marked as renamed)
- Pull changes from 'main' using this code
public void Pull(string branch)
{
using (var repo = new Repository(this.repoPath))
{
Configuration config = repo.Config;
var mergeOptions = new MergeOptions
{
FailOnConflict = true,
OnCheckoutProgress = OnCheckoutProgress
};
PullOptions options = new PullOptions
{
FetchOptions = new FetchOptions { CredentialsProvider = this.GetCredentialsProvider() },
MergeOptions = mergeOptions
};
var trackingBranch = repo.Branches[branch];
Signature buildSignature = config.BuildSignature(DateTimeOffset.Now);
var mergeResult = Commands.Pull(repo, buildSignature, options);
if (mergeResult.Status == MergeStatus.Conflicts)
{
repo.Merge(trackingBranch.TrackedBranch, buildSignature);
ConflictCollection conflicts = repo.Index.Conflicts;
var changes = new List<ContentChanges>();
foreach (Conflict conflict in conflicts)
{
// ...
}
}
}
}
Expected behavior
As mergeOptions.FindRenames == true it returns one conflict which has Ancestor==Readme.md, Ours==Readme2.md and Theirs==null (file deleted)
Actual behavior
It returns two conflicts.
First:

Second:

Version of LibGit2Sharp (release number or SHA1)
Latest: 4daf6189b0e20f878348b262d1846eb25bc6d7f6
Operating system(s) tested; .NET runtime tested
Windows .Net Fw 4.7.2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the conflict using the linked test_git repository and the Pull method with MergeOptions.FindRenames enabled. Start by examining Commands.Pull, repo.Merge, and repo.Index.Conflicts; done means the renamed-file case reports one conflict with the expected Ancestor, Ours, and Theirs values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, git
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100