Skip to content

Branch.IsCurrentRepositoryHead Throws NullReferenceException For Head in New Repo #105

Closed
@haacked

Description

@haacked

Ok, this is admittedly an edge case, but I thought I'd bring it up.

If you create a brand new repository, this property:

repo.Head.IsCurrentRepositoryHead

throws a NullReferenceException when you evaluate it.

To demonstrate the issue, I updated the test CanCreateBareRepo test, line 15 of RepositoryFixture, with two additional asserts.

repo.Head.CanonicalName.ShouldEqual("refs/heads/master");
repo.Head.IsCurrentRepositoryHead.ShouldBeTrue();

That second line throws a NullReferenceException when added to the existing unit test.

My guess is that:

repo.Head.IsCurrentRepositoryHead.ShouldBeTrue();

Should probably return true.

Though you could also argue that this is an invalid operation because there are no commits yet so refs/heads/master doesn't yet exist. But in that case, I still think an InvalidOperationException would be better than NulReferenceException. 😃

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions