Skip to content

Unable to delete file when the repository will be empty #723

@Erouan50

Description

@Erouan50

Hello,

First, thank you for this incredible package!

I get the following error when I try to remove the latest file in a repository and commit:

cannot create empty commit: clean working tree

I think the issue is due to the index entries being empty when the tree is built here:

if len(idx.Entries) == 0 && (opts == nil || !opts.AllowEmptyCommits) {

Here is a screenshot of my debugging session:

swappy-20230327-174441

You can see that the index entries are empty, but I have a change staged and ready to be committed.

Here is the code that you can use to reproduce my issue: https://gist.github.com/Erouan50/e2c8ec8d8ad21c7f3761b5f193ab6171#file-main-go

I'll create a pull request if you agree it is a bug.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions