Skip to content

fix: resolve relative paths correctly when creating worktrees from HEAD#2

Merged
wasabeef merged 6 commits intomainfrom
fix-create-worktree
Jul 1, 2025
Merged

fix: resolve relative paths correctly when creating worktrees from HEAD#2
wasabeef merged 6 commits intomainfrom
fix-create-worktree

Conversation

@wasabeef
Copy link
Copy Markdown
Owner

@wasabeef wasabeef commented Jun 30, 2025

Summary

This PR introduces several enhancements to git-workers v0.3.0:

1. Custom Path Support for Worktree Creation

  • Added a third option "Custom path (specify relative to project root)" when creating the first worktree
  • Allows users to specify arbitrary relative paths for flexible worktree organization
  • Comprehensive path validation with security checks to prevent path traversal attacks

2. Security and Robustness Improvements

  • Worktree Name Validation: Prevents invalid characters, reserved names, and non-ASCII warnings
  • File Copy Size Limits: Automatically skips files larger than 100MB with clear warnings
  • Concurrent Access Control: File-based locking prevents race conditions during worktree creation
  • Path Security: Validates custom paths against traversal attacks and excessive navigation

3. Bug Fixes

  • Fixed path resolution for non-bare repositories when creating worktrees from HEAD
  • Fixed format string issues to comply with clippy::uninlined_format_args
  • Fixed Ubuntu CI compatibility for worktree lock tests (handles different default branch names)

Key Changes

Custom Path Feature

// New validation function for custom paths
fn validate_custom_path(path: &str) -> Result<()> {
    // Comprehensive validation including:
    // - No absolute paths
    // - No excessive parent directory navigation
    // - No git reserved names in path components
    // - Cross-platform compatibility checks
}

Security Enhancements

  • Worktree names now reject filesystem-incompatible characters
  • File copy operations skip large files (>100MB) and symlinks
  • Lock files prevent concurrent worktree creation with automatic stale lock cleanup

Testing

  • Added 9 tests for custom path validation
  • Added 7 tests for worktree name validation
  • Added 6 tests for file size limits
  • Added 5 tests for concurrent access control
  • All tests pass on both macOS and Ubuntu

Breaking Changes

None - all changes are backward compatible.

Migration Guide

No migration needed. The custom path option is additive and doesn't affect existing workflows.

🤖 Generated with Claude Code

@wasabeef wasabeef force-pushed the fix-create-worktree branch from 2b55499 to 2c65b3f Compare June 30, 2025 15:22
@wasabeef wasabeef force-pushed the fix-create-worktree branch from 7aa02d2 to fc7a422 Compare June 30, 2025 17:24
@wasabeef wasabeef marked this pull request as ready for review June 30, 2025 17:42
@wasabeef wasabeef force-pushed the fix-create-worktree branch from 973341d to 8624a51 Compare June 30, 2025 18:50
@wasabeef wasabeef merged commit 4b35b3a into main Jul 1, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant