Skip to content

Reading Branch.UpstreamBranchCanonicalName throws an exception #1559

Open
@splatteredbits

Description

@splatteredbits

LibGit2 0.24.0. In C#, when I access the UpstreamBranchCanonicalName property on Branch I get this exception:

Message        : Value cannot be null.                                      
                 Parameter name: name                                       
ParamName      : name                                                       
Data           : {}                                                         
InnerException :                                                            
TargetSite     : System.String get_UpstreamBranchCanonicalName()            
StackTrace     :    at LibGit2Sharp.Branch.get_UpstreamBranchCanonicalName()
                    at LibGit2.Automation.BranchInfo..ctor(Branch branch)   
HelpLink       :                                                            
Source         : LibGit2Sharp                                               
HResult        : -2147467261                                                

I am enumerating the branches in PowerShell:

            $repo.Branches |
                ForEach-Object { New-Object LibGit2.Automation.BranchInfo $_ }

The constructor for my LibGit2.Automation.BranchInfo object is where Branch throws an exception:

        public BranchInfo(Branch branch)
        {
            Name = branch.FriendlyName;
            CanonicalName = branch.CanonicalName;
            UpstreamBranchCanonicalName = branch.UpstreamBranchCanonicalName;
            IsRemote = branch.IsRemote;
            IsTracking = branch.IsTracking;
            IsCurrentRepositoryHead = branch.IsCurrentRepositoryHead;
            Tip = new CommitInfo(branch.Tip);
        }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions