Skip to content

[1.x] Directory scanning returns 0 files in git worktree environments #417

@kgonyon

Description

@kgonyon

Pint Version

1.26.0

PHP Version

8.4.16

Description

I ran into this issue where in CI pint worked fine but on my local it didn't. I'm using git worktrees extensively when developing locally.

Description

When running Pint in a git worktree (where .git is a file pointing to the main repository, not a directory), directory scanning fails to find any files. However, passing files explicitly works correctly.

Environment Details

  • macOS (Darwin 25.1.0)
  • Git worktree (.git is a file containing gitdir: /path/to/main/repo/.git/worktrees/...)
  • Standard Laravel 11 project structure

Expected Behavior

./vendor/bin/pint app should scan all PHP files in the app directory recursively, regardless of whether the project is in a git worktree.

Actual Behavior

Directory scanning returns 0 files in worktree environments, but works when files are passed explicitly via glob patterns or find.

Workaround

./vendor/bin/pint $(find app routes -name "*.php")

Steps To Reproduce

  1. Create a git worktree:

    git worktree add ../my-worktree feature-branch
    cd ../my-worktree
  2. Run Pint on a directory:

    ./vendor/bin/pint app --test
    # Returns: PASS ... 0 files
  3. Run Pint with explicit files:

    ./vendor/bin/pint app/Http/Controllers/*.php --test
    # Returns: FAIL ... X files, Y style issues
  4. Confirm files exist:

    find app -name "*.php" | wc -l
    # Returns: 25

Metadata

Metadata

Assignees

No one assigned

    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