libgit2 / libgit2/libgit2sharp

Exception: "An item with the same key has already been added" while comparing commits

Open
#1,801 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
3.5k
Forks
925
PR merge metrics
No merged PRs in 30d

Description

Reproduction steps

repository.Diff.Compare<Patch>(commitB.Tree, commitA.Tree);

Expected behavior

patch

Actual behavior

"exception": "System.ArgumentException: An item with the same key has already been added. Key: tools/firmware-utils/src/bcm_tag.h\n at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)\n at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)\n at LibGit2Sharp.Patch..ctor(DiffHandle diff)\n at LibGit2Sharp.Diff.u003cu003ec.u003c.cctoru003eb__36_0(DiffHandle diff)\n at LibGit2Sharp.Diff.BuildDiffResult[T](DiffHandle diff)\n at LibGit2Sharp.Diff.Compare[T](Tree oldTree, Tree newTree, IEnumerable`1 paths, ExplicitPathsOptions explicitPathsOptions, CompareOptions compareOptions)\n at

Version of LibGit2Sharp (release number or SHA1)

libgit2sharp/0.26.2

Operating system(s) tested; .NET runtime tested

ubuntu docker mcr.microsoft.com/dotnet/core/aspnet:3.1-bionic

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing repository.Diff.Compare< Patch >(commitB.Tree, commitA.Tree) with the reported commits and review the stack trace through Diff.Compare and LibGit2Sharp.Patch. Inspect how the duplicate path tools/firmware-utils/src/bcm_tag.h is handled; done means the comparison returns a patch instead of throwing the duplicate-key exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, git
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.