libgit2 / libgit2/libgit2sharp

Diff compare with DiffTargets.WorkingDirectory is terribly slow

Open
#2,010 1 comment 1 reaction 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

Compare commit to the working tree directory on a relatively big repository

 repository.Diff.Compare<TreeChanges>(
              repository.Head.Tip.Tree,
              DiffTargets.WorkingDirectory)

which takes a long time or never completes. Comparing the working trees of two commits works instantly

                    var branchDiffResult = repository.Diff.Compare<TreeChanges>(
                       targetCommit.Tree,
                        repository.Head.Tip.Tree,
                        compareOptions);

Additionally, doing repository.RetrieveStatus() is also slow, but not that slow.

Expected behavior

The speed of the two matches.

Actual behavior

Comparing to working directory is terribly slow.

Version of LibGit2Sharp (release number or SHA1)

0.27.0.0

Operating system(s) tested; .NET runtime tested

4.72, windows 11

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

Reproduce the slowdown with repository.Diff.Compare(repository.Head.Tip.Tree, DiffTargets.WorkingDirectory) on a relatively large repository, then compare it with the commit-to-commit overload and repository.RetrieveStatus(). Trace the working-directory comparison path and measure where time is spent. Done means the working-directory comparison completes with performance comparable to the commit-to-commit comparison.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, git
Domain
backend-api-design, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.