Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference 'refs/notes/commits' not found when creating LibGit2Sharp.Repository object #1362

Closed
splatteredbits opened this issue Sep 6, 2016 · 2 comments

Comments

@splatteredbits
Copy link
Contributor

splatteredbits commented Sep 6, 2016

Windows 7/PowerShell 5/libgit2sharp 0.22

When I try to create a LibGit2Sharp.Repository object, I get this exception [1]

Steps to reproduce:

  1. Open PowerShell
  2. Load the assembly: add-type -Path .\LibGit2Sharp.dll
  3. Create a repository object: New-object 'LibGit2Sharp.Repository' 'F:\Build\LibGit2Sharp'

Note the exception.

[1]

Message        : Reference 'refs/notes/commits' not found
Data           : {libgit2.code, libgit2.category}
InnerException : 
TargetSite     : Void HandleError(Int32)
StackTrace     :    at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in c:\Git\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:line 160
                    at LibGit2Sharp.Core.Proxy.git_foreach[T1,T2,TResult](Func`3 resultSelector, Func`2 iterator, GitErrorCode[] ignoredErrorCodes) in c:\Git\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:line 3399
                    at LibGit2Sharp.NoteCollection.GetEnumerator() in c:\Git\libgit2sharp\LibGit2Sharp\NoteCollection.cs:line 41
HelpLink       : 
Source         : LibGit2Sharp
HResult        : -2146233088
@splatteredbits
Copy link
Contributor Author

I attached a debugger to see what is going on and it looks like the error happens when PowerShell tries to display the object. It enumerates (or tries to) the repository object and when there aren't any notes, we get the exception.

If I save the repository object to a variable, I don't get the error, e.g. $repo = New-object 'LibGit2Sharp.Repository' 'F:\Build\LibGit2Sharp'

What's the best way to gracefully handle when there aren't any notes?

splatteredbits added a commit to splatteredbits/libgit2sharp that referenced this issue Sep 7, 2016
…sitory that has no notes throws an exception.
ethomson added a commit that referenced this issue Jun 24, 2017
…ound

Fixed issue #1362: enumerating the notes collection for a repository …
@carlosmn
Copy link
Member

carlosmn commented Oct 8, 2017

Fixed vi #1363

@carlosmn carlosmn closed this as completed Oct 8, 2017
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

No branches or pull requests

2 participants