libgit2 / libgit2/libgit2sharp
Exception while trying to retrieve last commit from shallow repo
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 3.5k
- Forks
- 925
- PR merge metrics
- No merged PRs in 30d
Description
In my custom MSBuild task code tries to get last commit hash to put it into one of assembly attributes. Task works very well with repositories cloned with full depth but fails with the following error in repositories with limited depth created with command git clone --depth xx - where xx is number of last commits to clone.
/home/travis/build/DjvuNet/DjvuNet/DjvuNetBuild.Core.targets(20,5): error :
LibGit2Sharp.NotFoundException:
object not found - no match for id (d53e5a7166904479d42953bd0f91264f5ace1f6d)
[/home/travis/build/DjvuNet/DjvuNet/DjvuNet.NETStandard2.0/DjvuNet.NETStandard2.0.csproj]
Code used to retrieve commit data is as follows:
Repository repo = new Repository(RepoRoot);
var commits = repo.Commits;
var commit = commits.FirstOrDefault();
Seems to be libgit2sharp implementation bug as git fully supports enumeration of limited depth repos.
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
Start at the Repository.Commits entry point shown in the report and reproduce the failure with a repository created using git clone --depth xx. Compare enumeration of the shallow repository with the reported NotFoundException, then verify that retrieving the first commit succeeds without the missing-object error. No specific test file is named in the issue.
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