libgit2 / libgit2/libgit2sharp

repo.Network.ListReferences(remote) throwing exception "this remote has never connected" intermittently

Open
#1,668 0 comments 2 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

Calling repo.Network.ListReferences(remote) throws exception "this remote has never connected" intermittently. This is how I have called it ... if it matters

          string localRepoPath = "path to cloned folder";
          string remoteName = "origin";            
            using (Repository repo = new Repository(localRepoPath))
            {
                remoteName = repo.Network.Remotes.FirstOrDefault()?.Name ?? remoteName;
                Remote remote = repo.Network.Remotes[remoteName];                
                List<Reference> references = repo.Network.ListReferences(remote).ToList();
				
				// some more code logic here
			}

So am calling the overload of ListReferences(Remote remote) which essentially calls ListReferencesInternal(string url, CredentialsHandler credentialsProvider) passing null to CredentialsHandler. Should this be an issue? Don't think so since it's working in second try or so. Relevant exception stack trace below

{
"Depth": 1,
"ClassName": "",
"Message": "this remote has never connected",
"Source": "LibGit2Sharp",
"StackTraceString": " at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)\r\n at LibGit2Sharp.Core.Proxy.git_remote_ls(Repository repository, RemoteHandle remote)\r\n at LibGit2Sharp.Network.ListReferencesInternal(String url, CredentialsHandler credentialsProvider)\r\n

Please suggest, what's wrong is going on (Or) if you need further information from my end.

Found this existing issue https://github.com/libgit2/libgit2sharp/issues/1504 but am not passing any credential, and it's a public repo which am trying to access.

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 with Network.ListReferences(Remote), ListReferencesInternal, and the git_remote_ls call shown in the stack trace. Reproduce the first and subsequent calls using the provided sample, then trace the intermittent remote state; done means the cause is identified and the failure has a regression test or a clearly documented resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, git
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.