Skip to content

pre-commit hook will fail on commits with .meta files for empty directories #4

Description

@aefreedman

The pre-commit hook will exit non-0 if there's a .meta file without a corresponding non-meta file. Empty directories in Unity will create .meta files, but Git won't allow you to add empty directories to the index. The conventional workaround for this is adding a .gitkeep dummy file in the directory to make Git "notice" the directory. However, adding an invisible file in a directory doesn't create a .meta file for it, causing the same problem.

If you're using Rider in an empty project, this will always lead to an error loop, since the plugin will add an Assets/Plugins/Editor folder, while we've ignored the JetBrains folder that gets added to it. A .meta file for the directory is created, but Git thinks the directory is empty. (It doesn't really make any sense to me, since it sees the .meta file, but whatever.)

Adding any unignored Unity asset to the editor folder will trigger Git to add the folder to the index, but that's a rather silly solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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