Open
Description
Environment
- ggshield version: latest
- Operating system (Linux, macOS, Windows): WSL2 within Windows
- Operating system version: Windows 11
- Python version:
Describe the bug
I am using a Git worktree. When I commit to the initial worktree directory, the pre-commit check passes. When committing to another Git worktree directory, the path doesn't resolve and there's a message saying it's not a git repository.
Steps to reproduce:
- clone a Git repository locally
- add another branch from the same repository as a Git worktree:
git worktree add ../other-branch-dir feature/my_other_branch
- Run
ggshield secret scan pre-commit
- An error occurs
Actual result:
git commit -m "TESTING COMMIT IN WORKTREE"
latest: Pulling from someplace/ggshield
Digest: sha256:2eb6blahblah
Status: Image is up to date for quay.io/someplace/ggshield:latest
quay.io/someplace/ggshield:latest
fatal: not a git repository: /code/../original-server-code-dir/worktrees/other-branch-dir
make: *** [.make/tools-ggshield.mk:11: ggshield/pre-commit] Error 128
The make target runs the following using Docker:
@docker run -i --rm \
-v .:/code \
--workdir /code \
--env-file .env \
--platform=linux/amd64 \
$(GGSHIELD_IMAGE) ggshield secret scan pre-commit
Expected result:
The ggshield check passes without error. This is the output when committing from the original folder:
latest: Pulling from someplace/ggshield
Digest: sha256:2eb6blahblah
Status: Image is up to date for quay.io/someplace/ggshield:latest
quay.io/someplace/ggshield:latest
No secrets have been found
[feature/my_original_branch 44blahblah] TEST COMMIT
If applicable, add logs or screenshots to help explain your problem.