Skip to content

Handle empty list of commits in new repository #1155

@jrmhaig

Description

@jrmhaig

I started to create a PR for this issue as it is simple and then I saw in CONTRIBUTING.md

... it does not introduce unnecessary abstraction layers or modify Git's core functionality.

so I think that raising an issue to ask is more sensible.

My first attempt with this gem was to try

repo = Git.open(File.expand_path('source', __dir__))
repo.log.execute

on a new and completely empty repository. This results in an exception being thrown as git log exits with a fatal error.

$ git log
fatal: your current branch 'master' does not have any commits yet

I would expect this to fail silently and return an empty array but I appreciate that this differs from the functionality of git. Is this a change that you would consider?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions