fix: Git directory is not resolved if GIT_WORK_TREE is set to relative path #887
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolving the git directory failed if the environment variable
GIT_WORK_TREE
is set to a relative path and lint-staged is run from a subdirectory of a Git repository (e.g. multi-package repos).GIT_WORK_TREE
can be used to set the worktree directory for a Git repo.GIT_DIR
specifies only the.git
directory path.git rev-parse --show-toplevel
will return the Git worktree directory. If it is set to a relative path, it won't work when git commands are called from a subdirectory, as the relative path will fail to resolve correctly.While
GIT_DIR
is unset inresolveGitRepo.js
,GIT_WORK_TREE
was not. UnsettingGIT_WORK_TREE
in the same place fixes the issue.Resolves #886