Repository navigation
fix: reject unsafe Git configuration before running GTR - #225
Conversation
|
No actionable comments were generated in the recent review. WalkthroughGTR now validates native Git configuration ownership and write access before using configuration. CLI startup, hook dispatch, and generated Bash, Zsh, and Fish helpers enforce the checks. The shell integration cache schema is now 9. Tests, CI setup, and documentation cover the new behavior. ChangesGit configuration safety
Estimated code review effort: 4 (Complex) | ~45 minutes Change: Bug fix · Severity of issue fixed: High Sequence Diagram(s)sequenceDiagram
actor User
participant CLI as git-gtr
participant Check as _gtr_config_check
participant Git
participant Hooks as run_hooks
User->>CLI: Run a GTR command
CLI->>Check: Validate configuration
Check->>Git: Read configuration sources and includes
Git-->>Check: Return configuration origins and paths
Check-->>CLI: Return validation result
CLI->>Hooks: Dispatch configured hooks
Hooks->>Check: Recheck configuration
Check->>Git: Read configuration for the current worktree
Git-->>Check: Return configuration origins and paths
Check-->>Hooks: Return validation result
Suggested reviewers: Merge Risk:
|
Description
Reject unsafe native Git configuration before GTR uses it. For example, a group-writable
.git/configcontaininggtr.hook.postCreateandgtr.worktrees.dirpreviously ran the hook and created a worktree at the supplied destination. It now produces an error before creating the branch, directory, or hook marker.The runtime validator checks ownership, group/other write permissions, macOS write-capable ACLs, included files, symlinks, and parent directories. Protected configuration retains its existing behavior. CLI startup and hook dispatch enforce the check, and generated Bash/Zsh/Fish helpers embed the same validator. Shell cache schema 9 replaces older generated helpers when integration is refreshed.
Motivation
A shared writable configuration file must not implicitly authorize another OS user's GTR hooks or destination settings. This introduces an actual runtime refusal for that case.
Type of Change
Testing
Tested on macOS with Git 2.50.1, Bash 3.2.57 and 5.3.20, Zsh 5.9, and Fish 4.9.3.
Linux CI and the macOS Bash 3.2 CI check pass. Windows/Git Bash and a live second-UID fixture have not been tested; regression fixtures use disposable repositories and controlled permissions, with no account or system permission changes.
Breaking Changes
Group/other-writable Git configuration, unsafe parent paths, foreign ownership, and macOS write-capable ACL grants stop GTR. Fix the reported path's ownership/permissions or use a private clone. The documentation includes migration guidance;
git gtr trustdoes not override the filesystem check. Reload shell setup after upgrading to replace already-loaded old functions.Checklist
License Acknowledgment
This contribution is made under the Apache License 2.0.
Summary by CodeRabbit
git gtr trustdoes not bypass these checks.