Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

refactor: consolidate .git/wt-* paths under .git/wt/ and stage removed worktrees in trash (#1583)

worktrunk-botce9ea1a6b61a
diff --git a/CLAUDE.md b/CLAUDE.md
index 76d89b8c2..527243736 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -238,7 +238,7 @@ When no structured alternative exists, document the fragility inline.
## Background Operation Logs
-All background logs are centralized in `.git/wt-logs/` (main worktree's git directory):
+All background logs are centralized in `.git/wt/logs/` (main worktree's git directory):
- **Post-start commands**: `{branch}-{source}-post-start-{command}.log` (source: `user` or `project`)
- **Background removal**: `{branch}-remove.log`
@@ -247,7 +247,7 @@ Examples: `feature-user-post-start-npm.log`, `feature-project-post-start-build.l
### Log Behavior
-- **Centralized**: All logs go to main worktree's `.git/wt-logs/`, shared across all worktrees
+- **Centralized**: All logs go to main worktree's `.git/wt/logs/`, shared across all worktrees
- **Overwrites**: Same operation on same branch overwrites previous log (prevents accumulation)
- **Not tracked**: Logs are in `.git/` directory, which git doesn't track
- **Manual cleanup**: Stale logs from deleted branches persist but are bounded by branch count
diff --git a/dev/wt.example.toml b/dev/wt.example.toml
index 6be027a9e..c505f2cc3 100644
--- a/dev/wt.example.toml
+++ b/dev/wt.example.toml
@@ -48,7 +48,7 @@
# Post-Start: Runs in BACKGROUND after worktree creation (parallel)
# Use for: dev servers, file watchers, background builds
-# Output logged to .git/wt-logs/{branch}-project-post-start-{name}.log
+# Output logged to .git/wt/logs/{branch}-project-post-start-{name}.log
#
# [post-start]
# server = "npm run dev -- --port {{ branch | hash_port }}"
diff --git a/docs/content/config.md b/docs/content/config.md
index 36485d5fd..24c72f41a 100644
--- a/docs/content/config.md
+++ b/docs/content/config.md
@@ -753,7 +753,7 @@ View and manage logs from background operations.
### What's logged
-Two kinds of logs live in `.git/wt-logs/`:
+Two kinds of logs live in `.git/wt/logs/`:
#### Command log (`commands.jsonl`)
@@ -770,7 +770,7 @@ Source is `user` or `project` depending on where the hook is defined.
### Location
-All logs are stored in `.git/wt-logs/` (in the main worktree's git directory).
+All logs are stored in `.git/wt/logs/` (in the main worktree's git directory).
### Behavior
@@ -787,12 +787,12 @@ wt config state logs get
Query the command log:
```bash
-tail -5 .git/wt-logs/commands.jsonl | jq .
+tail -5 .git/wt/logs/commands.jsonl | jq .
```
View a specific hook log:
```bash
-cat "$(git rev-parse --git-dir)/wt-logs/feature-project-post-start-build.log"
+cat "$(git rev-parse --git-dir)/wt/logs/feature-project-post-start-build.log"
```
Clear all logs:
diff --git a/docs/content/faq.md b/docs/content/faq.md
index f281e974b..4db91d680 100644
--- a/docs/content/faq.md
+++ b/docs/content/faq.md
@@ -114,9 +114,9 @@ Worktrunk stores small amounts of cache and log data in the repository's `.git/`
| Location | Purpose | Created by |
|----------|---------|------------|
| `.git/config` keys under `worktrunk.*` | Cached default branch, switch history, branch markers | Various commands |
-| `.git/wt-cache/ci-status/*.json` | CI status cache (~1KB each) | `wt list` when `gh` or `glab` CLI is installed |
-| `.git/wt-logs/*.log` | Background command output | Hooks, background `wt remove` |
-| `.git/wt-logs/commands.jsonl` | Command audit log (~2MB max) | Hooks, LLM commands |
+| `.git/wt/cache/ci-status/*.json` | CI status cache (~1KB each) | `wt list` when `gh` or `glab` CLI is installed |
+| `.git/wt/logs/*.log` | Background command output | Hooks, background `wt remove` |
+| `.git/wt/logs/commands.jsonl` | Command audit log (~2MB max) | Hooks, LLM commands |
None of this is tracked by git or pushed to remotes.
@@ -193,16 +193,16 @@ Use `--yes` to bypass prompts (useful for CI/automation).
### Command log
-All hook executions and LLM commands are recorded in `.git/wt-logs/commands.jsonl` — one JSON object per line with timestamp, command, exit code, and duration. This provides a debugging trail without requiring `-vv` verbose output. The file rotates to `commands.jsonl.old` at 1MB, bounding storage to ~2MB.
+All hook executions and LLM commands are recorded in `.git/wt/logs/commands.jsonl` — one JSON object per line with timestamp, command, exit code, and duration. This provides a debugging trail without requiring `-vv` verbose output. The file rotates to `commands.jsonl.old` at 1MB, bounding storage to ~2MB.
View the log with `wt config state logs get`, or query directly:
```bash
# Recent commands
-tail -5 .git/wt-logs/commands.jsonl | jq .
+tail -5 .git/wt/logs/commands.jsonl | jq .
# Failed commands
-jq 'select(.exit != 0 and .exit != null)' .git/wt-logs/commands.jsonl
+jq 'select(.exit != 0 and .exit != null)' .git/wt/logs/commands.jsonl
```
Clear with `wt config state logs clear`.
diff --git a/docs/content/hook.md b/docs/content/hook.md
index f6927f746..b3fe01999 100644
--- a/docs/content/hook.md
+++ b/docs/content/hook.md
@@ -61,7 +61,7 @@ env = "echo 'PORT={{ branch | hash_port }}' > .env.local"
## post-start
-Dev servers, long builds, file watchers, copying caches. Output logged to `.git/wt-logs/{branch}-{source}-post-start-{name}.log`.
+Dev servers, long builds, file watchers, copying caches. Output logged to `.git/wt/logs/{branch}-{source}-post-start-{name}.log`.
```toml
[post-start]
@@ -71,7 +71,7 @@ server = "npm run dev -- --port {{ branch | hash_port }}"
## post-switch
-Triggers on all switch results: creating new worktrees, switching to existing ones, or staying on current. Output logged to `.git/wt-logs/{branch}-{source}-post-switch-{name}.log`.
+Triggers on all switch results: creating new worktrees, switching to existing ones, or staying on current. Output logged to `.git/wt/logs/{branch}-{source}-post-switch-{name}.log`.
```toml
[post-switch]
@@ -117,7 +117,7 @@ archive = "tar -czf ~/.wt-logs/{{ branch }}.tar.gz test-results/ logs/ 2>/dev/nu
## post-remove
-Cleanup tasks after worktree removal: stopping dev servers, removing containers, notifying external systems. All template variables reference the removed worktree, so cleanup scripts can identify resources to clean up. Output logged to `.git/wt-logs/{branch}-{source}-post-remove-{name}.log`.
+Cleanup tasks after worktree removal: stopping dev servers, removing containers, notifying external systems. All template variables reference the removed worktree, so cleanup scripts can identify resources to clean up. Output logged to `.git/wt/logs/{branch}-{source}-post-remove-{name}.log`.
```toml
[post-remove]
diff --git a/docs/content/remove.md b/docs/content/remove.md
index 299cf7b92..0ed78e35f 100644
--- a/docs/content/remove.md
+++ b/docs/content/remove.md
@@ -73,7 +73,7 @@ Without `--force`, removal fails if the worktree contains untracked files. Witho
## Background removal
-Removal runs in the background by default (returns immediately). Logs are written to `.git/wt-logs/{branch}-remove.log`. Use `--foreground` to run in the foreground.
+Removal runs in the background by default (returns immediately). Logs are written to `.git/wt/logs/{branch}-remove.log`. Use `--foreground` to run in the foreground.
## Hooks
diff --git a/skills/worktrunk/reference/config.md b/skills/worktrunk/reference/config.md
index 652e396fd..f56a845e4 100644
--- a/skills/worktrunk/reference/config.md
+++ b/skills/worktrunk/reference/config.md
@@ -732,7 +732,7 @@ View and manage logs from background operations.
### What's logged
-Two kinds of logs live in `.git/wt-logs/`:
+Two kinds of logs live in `.git/wt/logs/`:
#### Command log (`commands.jsonl`)
@@ -749,7 +749,7 @@ Source is `user` or `project` depending on where the hook is defined.
### Location
-All logs are stored in `.git/wt-logs/` (in the main worktree's git directory).
+All logs are stored in `.git/wt/logs/` (in the main worktree's git directory).
### Behavior
@@ -766,12 +766,12 @@ wt config state logs get
Query the command log:
```bash
-tail -5 .git/wt-logs/commands.jsonl | jq .
+tail -5 .git/wt/logs/commands.jsonl | jq .
```
View a specific hook log:
```bash
-cat "$(git rev-parse --git-dir)/wt-logs/feature-project-post-start-build.log"
+cat "$(git rev-parse --git-dir)/wt/logs/feature-project-post-start-build.log"
```
Clear all logs:
diff --git a/skills/worktrunk/reference/faq.md b/skills/worktrunk/reference/faq.md
index 070de9b51..8fa6ca0ed 100644
--- a/skills/worktrunk/reference/faq.md
+++ b/skills/worktrunk/reference/faq.md
@@ -107,9 +107,9 @@ Worktrunk stores small amounts of cache and log data in the repository's `.git/`
| Location | Purpose | Created by |
|----------|---------|------------|
| `.git/config` keys under `worktrunk.*` | Cached default branch, switch history, branch markers | Various commands |
-| `.git/wt-cache/ci-status/*.json` | CI status cache (~1KB each) | `wt list` when `gh` or `glab` CLI is installed |
-| `.git/wt-logs/*.log` | Background command output | Hooks, background `wt remove` |
-| `.git/wt-logs/commands.jsonl` | Command audit log (~2MB max) | Hooks, LLM commands |
+| `.git/wt/cache/ci-status/*.json` | CI status cache (~1KB each) | `wt list` when `gh` or `glab` CLI is installed |
+| `.git/wt/logs/*.log` | Background command output | Hooks, background `wt remove` |
+| `.git/wt/logs/commands.jsonl` | Command audit log (~2MB max) | Hooks, LLM commands |
None of this is tracked by git or pushed to remotes.
@@ -182,16 +182,16 @@ Use `--yes` to bypass prompts (useful for CI/automation).
### Command log
-All hook executions and LLM commands are recorded in `.git/wt-logs/commands.jsonl` — one JSON object per line with timestamp, command, exit code, and duration. This provides a debugging trail without requiring `-vv` verbose output. The file rotates to `commands.jsonl.old` at 1MB, bounding storage to ~2MB.
+All hook executions and LLM commands are recorded in `.git/wt/logs/commands.jsonl` — one JSON object per line with timestamp, command, exit code, and duration. This provides a debugging trail without requiring `-vv` verbose output. The file rotates to `commands.jsonl.old` at 1MB, bounding storage to ~2MB.
View the log with `wt config state logs get`, or query directly:
```bash
# Recent commands
-tail -5 .git/wt-logs/commands.jsonl | jq .
+tail -5 .git/wt/logs/commands.jsonl | jq .
# Failed commands
-jq 'select(.exit != 0 and .exit != null)' .git/wt-logs/commands.jsonl
+jq 'select(.exit != 0 and .exit != null)' .git/wt/logs/commands.jsonl
```
Clear with `wt config state logs clear`.
diff --git a/skills/worktrunk/reference/hook.md b/skills/worktrunk/reference/hook.md
index f0b0c173c..fb4b12904 100644
--- a/skills/worktrunk/reference/hook.md
+++ b/skills/worktrunk/reference/hook.md
@@ -52,7 +52,7 @@ env = "echo 'PORT={{ branch | hash_port }}' > .env.local"
## post-start
-Dev servers, long builds, file watchers, copying caches. Output logged to `.git/wt-logs/{branch}-{source}-post-start-{name}.log`.
+Dev servers, long builds, file watchers, copying caches. Output logged to `.git/wt/logs/{branch}-{source}-post-start-{name}.log`.
```toml
[post-start]
@@ -62,7 +62,7 @@ server = "npm run dev -- --port {{ branch | hash_port }}"
## post-switch
-Triggers on all switch results: creating new worktrees, switching to existing ones, or staying on current. Output logged to `.git/wt-logs/{branch}-{source}-post-switch-{name}.log`.
+Triggers on all switch results: creating new worktrees, switching to existing ones, or staying on current. Output logged to `.git/wt/logs/{branch}-{source}-post-switch-{name}.log`.
```toml
[post-switch]
@@ -108,7 +108,7 @@ archive = "tar -czf ~/.wt-logs/{{ branch }}.tar.gz test-results/ logs/ 2>/dev/nu
## post-remove
-Cleanup tasks after worktree removal: stopping dev servers, removing containers, notifying external systems. All template variables reference the removed worktree, so cleanup scripts can identify resources to clean up. Output logged to `.git/wt-logs/{branch}-{source}-post-remove-{name}.log`.
+Cleanup tasks after worktree removal: stopping dev servers, removing containers, notifying external systems. All template variables reference the removed worktree, so cleanup scripts can identify resources to clean up. Output logged to `.git/wt/logs/{branch}-{source}-post-remove-{name}.log`.
```toml
[post-remove]
diff --git a/skills/worktrunk/reference/remove.md b/skills/worktrunk/reference/remove.md
index 32389e796..dbd480c24 100644
--- a/skills/worktrunk/reference/remove.md
+++ b/skills/worktrunk/reference/remove.md
@@ -64,7 +64,7 @@ Without `--force`, removal fails if the worktree contains untracked files. Witho
## Background removal
-Removal runs in the background by default (returns immediately). Logs are written to `.git/wt-logs/{branch}-remove.log`. Use `--foreground` to run in the foreground.
+Removal runs in the background by default (returns immediately). Logs are written to `.git/wt/logs/{branch}-remove.log`. Use `--foreground` to run in the foreground.
## Hooks
diff --git a/skills/worktrunk/reference/troubleshooting.md b/skills/worktrunk/reference/troubleshooting.md
index 4062dec5c..125fbbc6f 100644
--- a/skills/worktrunk/reference/troubleshooting.md
+++ b/skills/worktrunk/reference/troubleshooting.md
@@ -59,7 +59,7 @@ Debug steps:
1. Run the command manually in the worktree to see errors
2. Check for missing dependencies (npm packages, system tools)
3. Verify template variables expand correctly (`wt hook show --verbose`)
-4. For background hooks, check `.git/wt-logs/` for output
+4. For background hooks, check `.git/wt/logs/` for output
### Slow blocking hooks
diff --git a/src/cli/config.rs b/src/cli/config.rs
index 842f4c1c7..c6eb478f6 100644
--- a/src/cli/config.rs
+++ b/src/cli/config.rs
@@ -438,7 +438,7 @@ Without a subcommand, runs `get` for the current branch. For `--branch`, use `ge
## What's logged
-Two kinds of logs live in `.git/wt-logs/`:
+Two kinds of logs live in `.git/wt/logs/`:
### Command log (`commands.jsonl`)
@@ -455,7 +455,7 @@ Source is `user` or `project` depending on where the hook is defined.
## Location
-All logs are stored in `.git/wt-logs/` (in the main worktree's git directory).
+All logs are stored in `.git/wt/logs/` (in the main worktree's git directory).
## Behavior
@@ -472,12 +472,12 @@ wt config state logs get
Query the command log:
```console
-tail -5 .git/wt-logs/commands.jsonl | jq .
+tail -5 .git/wt/logs/commands.jsonl | jq .
```
View a specific hook log:
```console
-cat "$(git rev-parse --git-dir)/wt-logs/feature-project-post-start-build.log"
+cat "$(git rev-parse --git-dir)/wt/logs/feature-project-post-start-build.log"
```
Clear all logs:
diff --git a/src/cli/mod.rs b/src/cli/mod.rs
index 4fba57a20..1ed3915d5 100644
--- a/src/cli/mod.rs
+++ b/src/cli/mod.rs
@@ -812,7 +812,7 @@ Without `--force`, removal fails if the worktree contains untracked files. Witho
## Background removal
-Removal runs in the background by default (returns immediately). Logs are written to `.git/wt-logs/{branch}-remove.log`. Use `--foreground` to run in the foreground.
+Removal runs in the background by default (returns immediately). Logs are written to `.git/wt/logs/{branch}-remove.log`. Use `--foreground` to run in the foreground.
## Hooks
@@ -1148,7 +1148,7 @@ env = "echo 'PORT={{ branch | hash_port }}' > .env.local"
## post-start
-Dev servers, long builds, file watchers, copying caches. Output logged to `.git/wt-logs/{branch}-{source}-post-start-{name}.log`.
+Dev servers, long builds, file watchers, copying caches. Output logged to `.git/wt/logs/{branch}-{source}-post-start-{name}.log`.
```toml
[post-start]
@@ -1158,7 +1158,7 @@ server = "npm run dev -- --port {{ branch | hash_port }}"
## post-switch
-Triggers on all switch results: creating new worktrees, switching to existing ones, or staying on current. Output logged to `.git/wt-logs/{branch}-{source}-post-switch-{name}.log`.
+Triggers on all switch results: creating new worktrees, switching to existing ones, or staying on current. Output logged to `.git/wt/logs/{branch}-{source}-post-switch-{name}.log`.
```toml
[post-switch]
@@ -1204,7 +1204,7 @@ archive = "tar -czf ~/.wt-logs/{{ branch }}.tar.gz test-results/ logs/ 2>/dev/nu
## post-remove
-Cleanup tasks after worktree removal: stopping dev servers, removing containers, notifying external systems. All template variables reference the removed worktree, so cleanup scripts can identify resources to clean up. Output logged to `.git/wt-logs/{branch}-{source}-post-remove-{name}.log`.
+Cleanup tasks after worktree removal: stopping dev servers, removing containers, notifying external systems. All template variables reference the removed worktree, so cleanup scripts can identify resources to clean up. Output logged to `.git/wt/logs/{branch}-{source}-post-remove-{name}.log`.
```toml
[post-remove]
diff --git a/src/command_log.rs b/src/command_log.rs
index 81242f376..8a25e4406 100644
--- a/src/command_log.rs
+++ b/src/command_log.rs
@@ -1,6 +1,6 @@
//! Always-on logging for configured external commands.
//!
-//! Logs hook execution and LLM commands to `.git/wt-logs/commands.jsonl` as JSONL.
+//! Logs hook execution and LLM commands to `.git/wt/logs/commands.jsonl` as JSONL.
//! Provides an audit trail for debugging without requiring `-vv`.
//!
//! # Growth control
diff --git a/src/commands/config/state.rs b/src/commands/config/state.rs
index 3d1e98da7..f161f8896 100644
--- a/src/commands/config/state.rs
+++ b/src/commands/config/state.rs
@@ -37,7 +37,7 @@ pub fn require_user_config_path() -> anyhow::Result<PathBuf> {
// ==================== Log Management ====================
-/// Check if a file in `.git/wt-logs/` is a worktrunk log file.
+/// Check if a file in `.git/wt/logs/` is a worktrunk log file.
///
/// Matches `.log` (hook output), `.jsonl` (command audit log), and `.jsonl.old` (rotated).
fn is_wt_log_file(path: &std::path::Path) -> bool {
@@ -47,7 +47,7 @@ fn is_wt_log_file(path: &std::path::Path) -> bool {
name.ends_with(".log") || name.ends_with(".jsonl") || name.ends_with(".jsonl.old")
}
-/// Clear all log files from the wt-logs directory
+/// Clear all log files from the wt/logs directory
fn clear_logs(repo: &Repository) -> anyhow::Result<usize> {
let log_dir = repo.wt_logs_dir();
diff --git a/src/commands/list/ci_status/cache.rs b/src/commands/list/ci_status/cache.rs
index dda059c5e..cfdf558c8 100644
--- a/src/commands/list/ci_status/cache.rs
+++ b/src/commands/list/ci_status/cache.rs
@@ -1,6 +1,6 @@
//! CI status caching.
//!
-//! Caches CI status in `.git/wt-cache/ci-status/<branch>.json` to avoid
+//! Caches CI status in `.git/wt/cache/ci-status/<branch>.json` to avoid
//! hitting API rate limits.
use std::collections::hash_map::DefaultHasher;
@@ -14,7 +14,7 @@ use worktrunk::path::sanitize_for_filename;
use super::PrStatus;
-/// Cached CI status stored in `.git/wt-cache/ci-status/<branch>.json`
+/// Cached CI status stored in `.git/wt/cache/ci-status/<branch>.json`
///
/// Uses file-based caching instead of git config to avoid file locking issues.
/// On Windows, concurrent `git config` writes can temporarily lock `.git/config`,
@@ -66,9 +66,9 @@ impl CachedCiStatus {
self.head == current_head && now_secs.saturating_sub(self.checked_at) < ttl
}
- /// Get the cache directory path: `.git/wt-cache/ci-status/`
+ /// Get the cache directory path: `.git/wt/cache/ci-status/`
fn cache_dir(repo: &Repository) -> PathBuf {
- repo.git_common_dir().join("wt-cache").join("ci-status")
+ repo.wt_dir().join("cache").join("ci-status")
}
/// Get the cache file path for a branch.
diff --git a/src/commands/list/ci_status/mod.rs b/src/commands/list/ci_status/mod.rs
index 0ed0be9f5..7d83d7f9e 100644
--- a/src/commands/list/ci_status/mod.rs
+++ b/src/commands/list/ci_status/mod.rs
@@ -330,7 +330,7 @@ impl PrStatus {
/// Returns None if no CI found or CLI tools unavailable
///
/// # Caching
- /// Results (including None) are cached in `.git/wt-cache/ci-status/<branch>.json`
+ /// Results (including None) are cached in `.git/wt/cache/ci-status/<branch>.json`
/// for 30-60 seconds to avoid hitting GitHub API rate limits. TTL uses deterministic jitter
/// based on repo path to spread cache expirations across concurrent statuslines. Invalidated
/// when HEAD changes.
diff --git a/src/commands/process.rs b/src/commands/process.rs
index d0162dd9f..62d49db10 100644
--- a/src/commands/process.rs
+++ b/src/commands/process.rs
@@ -185,7 +185,7 @@ fn posix_command_separator(command: &str) -> &'static str {
/// - On Unix: uses process_group(0) to create a new process group (survives PTY closure)
/// - On Windows: uses CREATE_NEW_PROCESS_GROUP to detach from console
///
-/// Logs are centralized in the main worktree's `.git/wt-logs/` directory.
+/// Logs are centralized in the main worktree's `.git/wt/logs/` directory.
///
/// # Arguments
/// * `repo` - Repository instance for accessing git common directory
@@ -372,18 +372,19 @@ fn spawn_detached_windows(
/// Generate a staging path for worktree removal.
///
-/// Creates a sibling path with a unique suffix to enable instant rename-based removal.
-/// The path is guaranteed to be on the same filesystem as the original worktree
-/// (sibling paths share the same parent directory).
+/// Places the staging directory inside `.git/wt/trash/` so it is hidden from the
+/// user's workspace. For the main worktree, `.git/` is on the same filesystem,
+/// so `rename()` is an instant metadata operation. Linked worktrees on different
+/// mount points will get EXDEV and fall back to legacy removal.
///
-/// Format: `<path>.wt-removing-<timestamp>`
-pub fn generate_removing_path(worktree_path: &Path) -> PathBuf {
+/// Format: `<wt/trash>/<name>-<timestamp>`
+pub fn generate_removing_path(trash_dir: &Path, worktree_path: &Path) -> PathBuf {
let timestamp = epoch_now();
let name = worktree_path
.file_name()
.map(|n| n.to_string_lossy())
.unwrap_or_default();
- worktree_path.with_file_name(format!("{}.wt-removing-{}", name, timestamp))
+ trash_dir.join(format!("{}-{}", name, timestamp))
}
/// Build shell command for background removal of a staged (renamed) worktree.
@@ -586,22 +587,19 @@ mod tests {
#[test]
fn test_generate_removing_path() {
+ let trash_dir = PathBuf::from("/tmp/repo/.git/wt/trash");
let path = PathBuf::from("/tmp/my-project.feature");
- let removing_path = generate_removing_path(&path);
+ let removing_path = generate_removing_path(&trash_dir, &path);
- // Should be a sibling path (same parent)
- assert_eq!(removing_path.parent(), path.parent());
+ // Should be inside the trash directory
+ assert_eq!(removing_path.parent(), Some(trash_dir.as_path()));
// Should have the expected prefix
let name = removing_path.file_name().unwrap().to_string_lossy();
- assert!(
- name.starts_with("my-project.feature.wt-removing-"),
- "got: {}",
- name
- );
+ assert!(name.starts_with("my-project.feature-"), "got: {}", name);
// Should have a timestamp suffix (digits only after the prefix)
- let timestamp_part = name.trim_start_matches("my-project.feature.wt-removing-");
+ let timestamp_part = name.trim_start_matches("my-project.feature-");
assert!(
timestamp_part.chars().all(|c| c.is_ascii_digit()),
"timestamp part should be numeric: {}",
@@ -611,14 +609,14 @@ mod tests {
#[test]
fn test_build_remove_command_staged() {
- let staged_path = PathBuf::from("/tmp/my-project.feature.wt-removing-1234567890");
+ let staged_path = PathBuf::from("/tmp/repo/.git/wt/trash/my-project.feature-1234567890");
let original_path = PathBuf::from("/tmp/my-project.feature");
- assert_snapshot!(build_remove_command_staged(&staged_path, &original_path), @"sleep 1 && rmdir -- /tmp/my-project.feature 2>/dev/null; rm -rf -- /tmp/my-project.feature.wt-removing-1234567890");
+ assert_snapshot!(build_remove_command_staged(&staged_path, &original_path), @"sleep 1 && rmdir -- /tmp/my-project.feature 2>/dev/null; rm -rf -- /tmp/repo/.git/wt/trash/my-project.feature-1234567890");
// Shell escaping for special characters (space in path)
- let special_path = PathBuf::from("/tmp/test worktree.wt-removing-123");
+ let special_path = PathBuf::from("/tmp/repo/.git/wt/trash/test worktree-123");
let special_original = PathBuf::from("/tmp/test worktree");
- assert_snapshot!(build_remove_command_staged(&special_path, &special_original), @"sleep 1 && rmdir -- '/tmp/test worktree' 2>/dev/null; rm -rf -- '/tmp/test worktree.wt-removing-123'");
+ assert_snapshot!(build_remove_command_staged(&special_path, &special_original), @"sleep 1 && rmdir -- '/tmp/test worktree' 2>/dev/null; rm -rf -- '/tmp/repo/.git/wt/trash/test worktree-123'");
}
#[test]
diff --git a/src/commands/relocate.rs b/src/commands/relocate.rs
index 2c18b5594..ff1a9f1cd 100644
--- a/src/commands/relocate.rs
+++ b/src/commands/relocate.rs
@@ -274,7 +274,7 @@ impl RelocationExecutor {
validated: Vec<ValidatedCandidate>,
clobber: bool,
) -> anyhow::Result<Self> {
- let temp_dir = repo.git_common_dir().join("wt-relocate-tmp");
+ let temp_dir = repo.wt_dir().join("staging/relocate");
// Build map of current locations for cycle detection
let mut current_locations: HashMap<PathBuf, usize> = HashMap::new();
diff --git a/src/commands/select/summary.rs b/src/commands/select/summary.rs
index 5dde07f3c..48884a5bb 100644
--- a/src/commands/select/summary.rs
+++ b/src/commands/select/summary.rs
@@ -154,7 +154,9 @@ mod tests {
use crate::summary::{CachedSummary, read_cache, write_cache};
let (_dir, repo) = temp_repo();
// Block cache directory creation by placing a file where the directory should be
- let cache_parent = repo.git_common_dir().join("wt-cache");
+ let wt_dir = repo.wt_dir();
+ fs::create_dir_all(&wt_dir).unwrap();
+ let cache_parent = wt_dir.join("cache");
fs::write(&cache_parent, "blocker").unwrap();
let cached = CachedSummary {
@@ -226,7 +228,7 @@ mod tests {
use crate::summary::cache_dir;
let (_dir, repo) = temp_repo();
let dir = cache_dir(&repo);
- assert!(dir.to_str().unwrap().contains("wt-cache"));
+ assert!(dir.to_str().unwrap().contains("wt"));
assert!(dir.to_str().unwrap().contains("summaries"));
}
diff --git a/src/commands/step_commands.rs b/src/commands/step_commands.rs
index 6f17e1ec1..814a061a7 100644
--- a/src/commands/step_commands.rs
+++ b/src/commands/step_commands.rs
@@ -945,7 +945,7 @@ fn copy_and_remove(src: &Path, dest: &Path, is_dir: bool) -> anyhow::Result<()>
Ok(())
}
-const PROMOTE_STAGING_DIR: &str = "wt-promote-staging";
+const PROMOTE_STAGING_DIR: &str = "staging/promote";
/// Move gitignored files from both worktrees into a staging directory.
///
@@ -960,7 +960,7 @@ fn stage_ignored(
path_b: &Path,
entries_b: &[(PathBuf, bool)],
) -> anyhow::Result<(PathBuf, usize)> {
- let staging_dir = repo.git_common_dir().join(PROMOTE_STAGING_DIR);
+ let staging_dir = repo.wt_dir().join(PROMOTE_STAGING_DIR);
fs::create_dir_all(&staging_dir).context("creating promote staging directory")?;
let staging_a = staging_dir.join("a");
@@ -1096,7 +1096,7 @@ fn exchange_branches(
///
/// ## Interruption recovery
///
-/// The swap uses a staging directory at `.git/wt-promote-staging/` and proceeds
+/// The swap uses a staging directory at `.git/wt/staging/promote/` and proceeds
/// in three phases:
///
/// 1. **Stage**: move ignored files from both worktrees into staging (`a/`, `b/`)
@@ -1168,7 +1168,7 @@ pub fn handle_promote(branch: Option<&str>) -> anyhow::Result<PromoteResult> {
// Bail early if a leftover staging dir exists from a previous interrupted promote —
// it may contain the user's only copy of files from the failed swap.
// Check BEFORE ensure_clean so users see the recovery path first.
- let staging_path = repo.git_common_dir().join(PROMOTE_STAGING_DIR);
+ let staging_path = repo.wt_dir().join(PROMOTE_STAGING_DIR);
if staging_path.exists() {
return Err(anyhow::anyhow!(
"Files may need manual recovery from: {}\n\
diff --git a/src/diagnostic.rs b/src/diagnostic.rs
index c00c711de..172a79474 100644
--- a/src/diagnostic.rs
+++ b/src/diagnostic.rs
@@ -30,8 +30,8 @@
//!
//! # File Location
//!
-//! Reports are written to `<git-common-dir>/wt-logs/diagnostic.md` (typically
-//! `.git/wt-logs/diagnostic.md`). Verbose logs go to `verbose.log` in the same directory.
+//! Reports are written to `<git-common-dir>/wt/logs/diagnostic.md` (typically
+//! `.git/wt/logs/diagnostic.md`). Verbose logs go to `verbose.log` in the same directory.
//!
//! # Usage
//!
@@ -202,7 +202,7 @@ pub(crate) fn issue_hint() -> String {
/// Write diagnostic file when -vv is used.
///
/// Called at the end of command execution. If verbose level is >= 2, writes
-/// a diagnostic report to `.git/wt-logs/diagnostic.md` for issue filing.
+/// a diagnostic report to `.git/wt/logs/diagnostic.md` for issue filing.
///
/// Silently returns if:
/// - verbose < 2
diff --git a/src/git/repository/mod.rs b/src/git/repository/mod.rs
index 11b4d4875..a73d6f553 100644
--- a/src/git/repository/mod.rs
+++ b/src/git/repository/mod.rs
@@ -374,11 +374,28 @@ impl Repository {
&self.git_common_dir
}
+ /// Get the worktrunk data directory inside the git directory.
+ ///
+ /// Returns `<git-common-dir>/wt/` (typically `.git/wt/`).
+ /// All worktrunk-managed state lives under this single directory.
+ pub fn wt_dir(&self) -> PathBuf {
+ self.git_common_dir().join("wt")
+ }
+
/// Get the directory where worktrunk background logs are stored.
///
- /// Returns `<git-common-dir>/wt-logs/` (typically `.git/wt-logs/`).
+ /// Returns `<git-common-dir>/wt/logs/` (typically `.git/wt/logs/`).
pub fn wt_logs_dir(&self) -> PathBuf {
- self.git_common_dir().join("wt-logs")
+ self.wt_dir().join("logs")
+ }
+
+ /// Get the directory where worktrees are staged for background deletion.
+ ///
+ /// Returns `<git-common-dir>/wt/trash/` (typically `.git/wt/trash/`).
+ /// Worktrees are renamed here (instant same-filesystem rename) before
+ /// being deleted by a background process.
+ pub fn wt_trash_dir(&self) -> PathBuf {
+ self.wt_dir().join("trash")
}
/// The repository root path (the main worktree directory).
diff --git a/src/main.rs b/src/main.rs
index 9c41345bf..9b206d973 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -803,7 +803,7 @@ fn main() {
}
// Configure logging based on --verbose flag or RUST_LOG env var
- // When -vv is set, also write logs to .git/wt-logs/verbose.log
+ // When -vv is set, also write logs to .git/wt/logs/verbose.log
if cli.verbose >= 2 {
verbose_log::init();
}
diff --git a/src/output/handlers.rs b/src/output/handlers.rs
index a8a94a1fd..fb8654044 100644
--- a/src/output/handlers.rs
+++ b/src/output/handlers.rs
@@ -56,9 +56,11 @@ fn execute_instant_removal_or_fallback(
force_worktree: bool,
) -> String {
// Fast path: instant removal via rename-then-prune.
- // Rename worktree to staging path (instant on same filesystem), then prune
+ // Rename worktree into .git/wt/trash/ (instant on same filesystem), then prune
// git metadata. Background process just does `rm -rf` on the staged directory.
- let staged_path = generate_removing_path(worktree_path);
+ let trash_dir = repo.wt_trash_dir();
+ let _ = std::fs::create_dir_all(&trash_dir);
+ let staged_path = generate_removing_path(&trash_dir, worktree_path);
match std::fs::rename(worktree_path, &staged_path) {
Ok(()) => {
// Fast path succeeded - prune git metadata synchronously.
diff --git a/src/shell_exec.rs b/src/shell_exec.rs
index cb0c9e78f..50b842cb2 100644
--- a/src/shell_exec.rs
+++ b/src/shell_exec.rs
@@ -537,7 +537,7 @@ impl Cmd {
/// Mark this command as an external (user-configured) command for logging.
///
- /// When set, the command execution is logged to `.git/wt-logs/commands.jsonl`
+ /// When set, the command execution is logged to `.git/wt/logs/commands.jsonl`
/// with the given label (e.g., "pre-merge user:lint", "commit.generation").
pub fn external(mut self, label: impl Into<String>) -> Self {
self.external_label = Some(label.into());
diff --git a/src/summary.rs b/src/summary.rs
index c59db9282..ef776844e 100644
--- a/src/summary.rs
+++ b/src/summary.rs
@@ -1,7 +1,7 @@
//! Shared LLM summary generation for branches.
//!
//! Generates branch summaries using the configured LLM command, with caching
-//! in `.git/wt-cache/summaries/`. Summaries are invalidated when the combined
+//! in `.git/wt/cache/summaries/`. Summaries are invalidated when the combined
//! diff (branch diff + working tree diff) changes.
//!
//! Used by both `wt list --full` (Summary column) and `wt switch` (preview tab).
@@ -27,7 +27,7 @@ use crate::llm::{execute_llm_command, prepare_diff};
/// `HEAVY_OPS_SEMAPHORE` (4) but still bounded.
pub(crate) static LLM_SEMAPHORE: LazyLock<Semaphore> = LazyLock::new(|| Semaphore::new(8));
-/// Cached summary stored in `.git/wt-cache/summaries/<branch>.json`
+/// Cached summary stored in `.git/wt/cache/summaries/<branch>.json`
#[derive(Serialize, Deserialize)]
pub(crate) struct CachedSummary {
pub summary: String,
@@ -65,7 +65,7 @@ const SUMMARY_TEMPLATE: &str = r#"Write a summary of this branch's changes as a
/// Get the cache directory for summaries
pub(crate) fn cache_dir(repo: &Repository) -> PathBuf {
- repo.git_common_dir().join("wt-cache").join("summaries")
+ repo.wt_dir().join("cache").join("summaries")
}
/// Get the cache file path for a branch
diff --git a/src/verbose_log.rs b/src/verbose_log.rs
index 5aece8ee7..5c29a06df 100644
--- a/src/verbose_log.rs
+++ b/src/verbose_log.rs
@@ -1,7 +1,7 @@
//! Verbose log file management for diagnostics.
//!
//! When `--verbose` is passed, logs are written to both stderr AND
-//! `.git/wt-logs/verbose.log`. This file can be included in diagnostic
+//! `.git/wt/logs/verbose.log`. This file can be included in diagnostic
//! reports to help debug issues.
//!
//! # Usage
@@ -64,13 +64,13 @@ pub(crate) fn log_file_path() -> Option<PathBuf> {
})
}
-/// Try to create the verbose log file in the repo's wt-logs directory.
+/// Try to create the verbose log file in the repo's wt/logs directory.
///
fn try_create_log_file() -> Option<(PathBuf, File)> {
// Find the git repo from current directory
let repo = worktrunk::git::Repository::current().ok()?;
- // Get the wt-logs directory (creates it if needed)
+ // Get the wt/logs directory (creates it if needed)
let log_dir = repo.wt_logs_dir();
std::fs::create_dir_all(&log_dir).ok()?;
diff --git a/tests/integration_tests/bare_repository.rs b/tests/integration_tests/bare_repository.rs
index 09ec2b732..e22ec11d0 100644
--- a/tests/integration_tests/bare_repository.rs
+++ b/tests/integration_tests/bare_repository.rs
@@ -437,7 +437,7 @@ fn test_bare_repo_merge_workflow() {
#[test]
fn test_bare_repo_background_logs_location() {
// This test verifies that background operation logs go to the correct location
- // in bare repos (bare_repo/wt-logs/ instead of worktree/.git/wt-logs/)
+ // in bare repos (bare_repo/wt/logs/ instead of worktree/.git/wt/logs/)
let test = BareRepoTest::new();
// Create main worktree
@@ -468,7 +468,7 @@ fn test_bare_repo_background_logs_location() {
// Wait for background process to create log file (poll instead of fixed sleep)
// The key test is that the path is correct, not that content was written (background processes are flaky in tests)
// Log filename has hash suffix: feature-<hash>-remove-<hash>.log
- let log_dir = test.bare_repo_path().join("wt-logs");
+ let log_dir = test.bare_repo_path().join("wt/logs");
wait_for_file_count(&log_dir, "log", 1);
// Verify the log file matches expected pattern (feature-*-remove.log)
@@ -489,7 +489,7 @@ fn test_bare_repo_background_logs_location() {
);
// Verify it's NOT in the worktree's .git directory (which doesn't exist for linked worktrees)
- let wrong_dir = main_worktree.join(".git/wt-logs");
+ let wrong_dir = main_worktree.join(".git/wt/logs");
assert!(
!wrong_dir.exists()
|| std::fs::read_dir(&wrong_dir)
diff --git a/tests/integration_tests/config_state.rs b/tests/integration_tests/config_state.rs
index 193dbb431..0f91e9225 100644
--- a/tests/integration_tests/config_state.rs
+++ b/tests/integration_tests/config_state.rs
@@ -30,10 +30,10 @@ fn state_get_settings() -> insta::Settings {
settings
}
-/// Write CI status to the file-based cache at .git/wt-cache/ci-status/<branch>.json
+/// Write CI status to the file-based cache at .git/wt/cache/ci-status/<branch>.json
fn write_ci_cache(repo: &TestRepo, branch: &str, json: &str) {
let git_dir = repo.root_path().join(".git");
- let cache_dir = git_dir.join("wt-cache").join("ci-status");
+ let cache_dir = git_dir.join("wt").join("cache").join("ci-status");
std::fs::create_dir_all(&cache_dir).unwrap();
// Sanitize branch name for filename
@@ -480,16 +480,16 @@ fn test_state_get_logs_empty(repo: TestRepo) {
);
// Path separator varies by platform, so check for either / or \
assert!(
- stderr.contains(".git/wt-logs") || stderr.contains(".git\\wt-logs"),
- "Expected .git/wt-logs or .git\\wt-logs in output: {stderr}"
+ stderr.contains(".git/wt/logs") || stderr.contains(".git\\wt\\logs"),
+ "Expected .git/wt/logs or .git\\wt\\logs in output: {stderr}"
);
}
#[rstest]
fn test_state_get_logs_with_files(repo: TestRepo) {
- // Create wt-logs directory with hook output and command log files
+ // Create wt/logs directory with hook output and command log files
let git_dir = repo.root_path().join(".git");
- let log_dir = git_dir.join("wt-logs");
+ let log_dir = git_dir.join("wt/logs");
std::fs::create_dir_all(&log_dir).unwrap();
std::fs::write(
log_dir.join("feature-post-start-npm.log"),
@@ -520,9 +520,9 @@ fn test_state_get_logs_with_files(repo: TestRepo) {
#[rstest]
fn test_state_get_logs_dir_exists_no_log_files(repo: TestRepo) {
- // Create wt-logs directory with non-log files (empty of actual log files)
+ // Create wt/logs directory with non-log files (empty of actual log files)
let git_dir = repo.root_path().join(".git");
- let log_dir = git_dir.join("wt-logs");
+ let log_dir = git_dir.join("wt/logs");
std::fs::create_dir_all(&log_dir).unwrap();
std::fs::write(log_dir.join("README.txt"), "not a log file").unwrap();
std::fs::write(log_dir.join(".gitkeep"), "").unwrap();
@@ -553,9 +553,9 @@ fn test_state_clear_logs_empty(repo: TestRepo) {
#[rstest]
fn test_state_clear_logs_with_files(repo: TestRepo) {
- // Create wt-logs directory with hook output and command log files
+ // Create wt/logs directory with hook output and command log files
let git_dir = repo.root_path().join(".git");
- let log_dir = git_dir.join("wt-logs");
+ let log_dir = git_dir.join("wt/logs");
std::fs::create_dir_all(&log_dir).unwrap();
std::fs::write(log_dir.join("feature-post-start-npm.log"), "npm output").unwrap();
std::fs::write(log_dir.join("bugfix-remove.log"), "remove output").unwrap();
@@ -571,9 +571,9 @@ fn test_state_clear_logs_with_files(repo: TestRepo) {
#[rstest]
fn test_state_clear_logs_single_file(repo: TestRepo) {
- // Create wt-logs directory with one log file
+ // Create wt/logs directory with one log file
let git_dir = repo.root_path().join(".git");
- let log_dir = git_dir.join("wt-logs");
+ let log_dir = git_dir.join("wt/logs");
std::fs::create_dir_all(&log_dir).unwrap();
std::fs::write(log_dir.join("feature-remove.log"), "remove output").unwrap();
@@ -623,7 +623,7 @@ fn test_state_clear_all_comprehensive(repo: TestRepo) {
// Logs
let git_dir = repo.root_path().join(".git");
- let log_dir = git_dir.join("wt-logs");
+ let log_dir = git_dir.join("wt/logs");
std::fs::create_dir_all(&log_dir).unwrap();
std::fs::write(log_dir.join("feature-remove.log"), "output").unwrap();
@@ -651,7 +651,7 @@ fn test_state_clear_all_comprehensive(repo: TestRepo) {
== Some(1)
);
// CI cache is now file-based, verify the cache file is cleared
- let ci_cache_dir = git_dir.join("wt-cache").join("ci-status");
+ let ci_cache_dir = git_dir.join("wt").join("cache").join("ci-status");
assert!(
!ci_cache_dir.join("feature.json").exists(),
"CI cache file should be cleared"
@@ -775,7 +775,7 @@ fn test_state_get_comprehensive(repo: TestRepo) {
// Create log files
let git_dir = repo.root_path().join(".git");
- let log_dir = git_dir.join("wt-logs");
+ let log_dir = git_dir.join("wt/logs");
std::fs::create_dir_all(&log_dir).unwrap();
std::fs::write(log_dir.join("feature-post-start-npm.log"), "npm output").unwrap();
std::fs::write(log_dir.join("bugfix-remove.log"), "remove output").unwrap();
@@ -860,7 +860,7 @@ fn test_state_get_json_comprehensive(repo: TestRepo) {
fn test_state_get_json_with_logs(repo: TestRepo) {
// Create hook output and command log files
let git_dir = repo.root_path().join(".git");
- let log_dir = git_dir.join("wt-logs");
+ let log_dir = git_dir.join("wt/logs");
std::fs::create_dir_all(&log_dir).unwrap();
std::fs::write(log_dir.join("feature-post-start-npm.log"), "npm output").unwrap();
std::fs::write(log_dir.join("bugfix-remove.log"), "remove log output").unwrap();
@@ -1159,9 +1159,9 @@ fn test_state_hints_clear_specific_not_set(repo: TestRepo) {
#[rstest]
fn test_state_logs_get_hook_returns_path(repo: TestRepo) {
- // Create wt-logs directory with a post-start log file
+ // Create wt/logs directory with a post-start log file
let git_dir = repo.root_path().join(".git");
- let log_dir = git_dir.join("wt-logs");
+ let log_dir = git_dir.join("wt/logs");
std::fs::create_dir_all(&log_dir).unwrap();
let filename = hook_log_filename("main", "user", "post-start", "server");
let log_file = log_dir.join(&filename);
@@ -1185,7 +1185,7 @@ fn test_state_logs_get_hook_returns_path(repo: TestRepo) {
fn test_state_logs_get_hook_project_source(repo: TestRepo) {
// Test that project source logs are found with explicit format
let git_dir = repo.root_path().join(".git");
- let log_dir = git_dir.join("wt-logs");
+ let log_dir = git_dir.join("wt/logs");
std::fs::create_dir_all(&log_dir).unwrap();
let filename = hook_log_filename("main", "project", "post-start", "build");
let log_file = log_dir.join(&filename);
@@ -1208,7 +1208,7 @@ fn test_state_logs_get_hook_project_source(repo: TestRepo) {
fn test_state_logs_get_hook_internal_op(repo: TestRepo) {
// Test finding an internal operation log (e.g., "internal:remove")
let git_dir = repo.root_path().join(".git");
- let log_dir = git_dir.join("wt-logs");
+ let log_dir = git_dir.join("wt/logs");
std::fs::create_dir_all(&log_dir).unwrap();
let filename = internal_log_filename("main", "remove");
let log_file = log_dir.join(&filename);
@@ -1228,9 +1228,9 @@ fn test_state_logs_get_hook_internal_op(repo: TestRepo) {
#[rstest]
fn test_state_logs_get_hook_not_found(repo: TestRepo) {
- // Create wt-logs directory with some log files but not the requested one
+ // Create wt/logs directory with some log files but not the requested one
let git_dir = repo.root_path().join(".git");
- let log_dir = git_dir.join("wt-logs");
+ let log_dir = git_dir.join("wt/logs");
std::fs::create_dir_all(&log_dir).unwrap();
let other_filename = hook_log_filename("main", "user", "post-start", "other");
std::fs::write(log_dir.join(&other_filename), "other output").unwrap();
@@ -1279,9 +1279,9 @@ fn test_state_logs_get_hook_no_logs_dir(repo: TestRepo) {
#[rstest]
fn test_state_logs_get_hook_no_logs_for_branch(repo: TestRepo) {
- // Create wt-logs directory with logs for different branch
+ // Create wt/logs directory with logs for different branch
let git_dir = repo.root_path().join(".git");
- let log_dir = git_dir.join("wt-logs");
+ let log_dir = git_dir.join("wt/logs");
std::fs::create_dir_all(&log_dir).unwrap();
let other_branch_filename = hook_log_filename("other-branch", "user", "post-start", "server");
std::fs::write(log_dir.join(&other_branch_filename), "other output").unwrap();
@@ -1308,7 +1308,7 @@ fn test_state_logs_get_hook_with_branch_flag(repo: TestRepo) {
.unwrap();
let git_dir = repo.root_path().join(".git");
- let log_dir = git_dir.join("wt-logs");
+ let log_dir = git_dir.join("wt/logs");
std::fs::create_dir_all(&log_dir).unwrap();
let filename = hook_log_filename("feature", "user", "post-start", "dev");
std::fs::write(log_dir.join(&filename), "dev output").unwrap();
diff --git a/tests/integration_tests/diagnostic.rs b/tests/integration_tests/diagnostic.rs
index 523b9ea95..1713128bd 100644
--- a/tests/integration_tests/diagnostic.rs
+++ b/tests/integration_tests/diagnostic.rs
@@ -12,7 +12,7 @@
//! - `test_diagnostic_context_has_no_ansi_codes`: ANSI stripped for GitHub
//! - `test_diagnostic_verbose_log_contains_git_commands`: Log has useful data
//! - `test_diagnostic_saved_message_with_vv`: Output shows "Diagnostic saved" with -vv
-//! - `test_diagnostic_written_to_correct_location`: File in .git/wt-logs/
+//! - `test_diagnostic_written_to_correct_location`: File in .git/wt/logs/
//! - `test_diagnostic_gh_hint_with_vv`: Hint shows gist and issue URL when gh installed
use std::fs;
@@ -55,7 +55,7 @@ fn test_diagnostic_report_file_format(mut repo: TestRepo) {
let diagnostic_path = repo
.root_path()
.join(".git")
- .join("wt-logs")
+ .join("wt/logs")
.join("diagnostic.md");
assert!(
diagnostic_path.exists(),
@@ -101,7 +101,7 @@ fn test_diagnostic_not_created_without_vv(mut repo: TestRepo) {
let diagnostic_path = repo
.root_path()
.join(".git")
- .join("wt-logs")
+ .join("wt/logs")
.join("diagnostic.md");
assert!(
!diagnostic_path.exists(),
@@ -141,7 +141,7 @@ fn test_diagnostic_contains_required_sections(mut repo: TestRepo) {
let content = fs::read_to_string(
repo.root_path()
.join(".git")
- .join("wt-logs")
+ .join("wt/logs")
.join("diagnostic.md"),
)
.unwrap();
@@ -201,7 +201,7 @@ fn test_diagnostic_context_has_no_ansi_codes(mut repo: TestRepo) {
let content = fs::read_to_string(
repo.root_path()
.join(".git")
- .join("wt-logs")
+ .join("wt/logs")
.join("diagnostic.md"),
)
.unwrap();
@@ -228,7 +228,7 @@ fn test_diagnostic_verbose_log_contains_git_commands(mut repo: TestRepo) {
let content = fs::read_to_string(
repo.root_path()
.join(".git")
- .join("wt-logs")
+ .join("wt/logs")
.join("diagnostic.md"),
)
.unwrap();
@@ -276,7 +276,7 @@ fn test_diagnostic_saved_message_with_vv(mut repo: TestRepo) {
);
}
-/// Diagnostic file should be written to .git/wt-logs/diagnostic.md
+/// Diagnostic file should be written to .git/wt/logs/diagnostic.md
#[rstest]
fn test_diagnostic_written_to_correct_location(mut repo: TestRepo) {
repo.add_worktree("feature");
@@ -284,14 +284,14 @@ fn test_diagnostic_written_to_correct_location(mut repo: TestRepo) {
repo.wt_command().args(["list", "-vv"]).output().unwrap();
- // Should be in .git/wt-logs/ directory
- let wt_logs_dir = repo.root_path().join(".git").join("wt-logs");
+ // Should be in .git/wt/logs/ directory
+ let wt_logs_dir = repo.root_path().join(".git").join("wt/logs");
assert!(wt_logs_dir.exists());
let diagnostic_path = wt_logs_dir.join("diagnostic.md");
assert!(
diagnostic_path.exists(),
- "diagnostic.md should be in wt-logs"
+ "diagnostic.md should be in wt/logs"
);
// Should be a markdown file
@@ -313,7 +313,7 @@ fn test_verbose_log_file_created(mut repo: TestRepo) {
let verbose_log_path = repo
.root_path()
.join(".git")
- .join("wt-logs")
+ .join("wt/logs")
.join("verbose.log");
assert!(
verbose_log_path.exists(),
@@ -344,7 +344,7 @@ fn test_vv_writes_diagnostic_on_success(repo: TestRepo) {
let diagnostic_path = repo
.root_path()
.join(".git")
- .join("wt-logs")
+ .join("wt/logs")
.join("diagnostic.md");
assert!(
diagnostic_path.exists(),
@@ -381,7 +381,7 @@ fn test_vv_writes_diagnostic_on_error(mut repo: TestRepo) {
let diagnostic_path = repo
.root_path()
.join(".git")
- .join("wt-logs")
+ .join("wt/logs")
.join("diagnostic.md");
assert!(
diagnostic_path.exists(),
@@ -407,7 +407,7 @@ fn test_v_does_not_enable_logging(repo: TestRepo) {
assert!(output.status.success(), "Command should succeed");
// Neither diagnostic.md nor verbose.log should exist with just -v
- let wt_logs = repo.root_path().join(".git").join("wt-logs");
+ let wt_logs = repo.root_path().join(".git").join("wt/logs");
let diagnostic_path = wt_logs.join("diagnostic.md");
let verbose_log_path = wt_logs.join("verbose.log");
@@ -441,7 +441,7 @@ fn test_vv_outside_repo_no_crash() {
let diagnostic_path = temp_dir
.path()
.join(".git")
- .join("wt-logs")
+ .join("wt/logs")
.join("diagnostic.md");
assert!(
!diagnostic_path.exists(),
@@ -467,7 +467,7 @@ fn test_diagnostic_gh_hint_with_vv(mut repo: TestRepo) {
// Normalize the path in the hint. The path may be:
// - Quoted on Windows (drive letter colon requires POSIX escaping): 'D:/a/.../diagnostic.md'
- // - Unquoted on Unix (no special chars): _REPO_/.git/wt-logs/diagnostic.md
+ // - Unquoted on Unix (no special chars): _REPO_/.git/wt/logs/diagnostic.md
let normalized = regex::Regex::new(r"--web '?[^' \x1b]*diagnostic\.md'?")
.unwrap()
.replace(hint_line, "--web [DIAGNOSTIC_PATH]");
diff --git a/tests/integration_tests/e2e_shell_post_start.rs b/tests/integration_tests/e2e_shell_post_start.rs
index 6273f87c6..4aaa624a9 100644
--- a/tests/integration_tests/e2e_shell_post_start.rs
+++ b/tests/integration_tests/e2e_shell_post_start.rs
@@ -64,7 +64,7 @@ approved-commands = ["sleep 0.05 && echo 'Background task done' > bg_marker.txt"
// First check if log file was created (proves process was spawned)
// Logs are centralized in the common git directory
let git_common_dir = resolve_git_common_dir(&worktree_path);
- let log_dir = git_common_dir.join("wt-logs");
+ let log_dir = git_common_dir.join("wt/logs");
assert!(
log_dir.exists(),
"Log directory should exist at {}",
diff --git a/tests/integration_tests/list.rs b/tests/integration_tests/list.rs
index ec4c05a5a..5913fd4a6 100644
--- a/tests/integration_tests/list.rs
+++ b/tests/integration_tests/list.rs
@@ -1765,7 +1765,7 @@ fn mock_ci_status(repo: &TestRepo, branch: &str, status: &str, source: &str, is_
};
// Create cache directory and write file
- let cache_dir = git_path.join("wt-cache").join("ci-status");
+ let cache_dir = git_path.join("wt").join("cache").join("ci-status");
std::fs::create_dir_all(&cache_dir).unwrap();
// Use the same sanitization as production code for cache filenames
diff --git a/tests/integration_tests/post_start_commands.rs b/tests/integration_tests/post_start_commands.rs
index ca27d1cdf..d381f5e5b 100644
--- a/tests/integration_tests/post_start_commands.rs
+++ b/tests/integration_tests/post_start_commands.rs
@@ -751,7 +751,7 @@ approved-commands = ["sleep 0.1 && echo 'Background task done' > background.txt"
// Verify log file was created in the common git directory
let worktree_path = repo.root_path().parent().unwrap().join("repo.feature");
let git_common_dir = resolve_git_common_dir(&worktree_path);
- let log_dir = git_common_dir.join("wt-logs");
+ let log_dir = git_common_dir.join("wt/logs");
assert!(log_dir.exists());
// Wait for the background command to complete
@@ -896,7 +896,7 @@ approved-commands = ["echo 'stdout output' && echo 'stderr output' >&2"]
// Wait for log file to be created (not just the directory)
let worktree_path = repo.root_path().parent().unwrap().join("repo.feature");
let git_common_dir = resolve_git_common_dir(&worktree_path);
- let log_dir = git_common_dir.join("wt-logs");
+ let log_dir = git_common_dir.join("wt/logs");
wait_for_file_count(&log_dir, "log", 1);
// Find the log file
@@ -985,7 +985,7 @@ approved-commands = [
// Wait for all 3 log files to be created (poll, don't use fixed sleep)
let worktree_path = repo.root_path().parent().unwrap().join("repo.feature");
let git_common_dir = resolve_git_common_dir(&worktree_path);
- let log_dir = git_common_dir.join("wt-logs");
+ let log_dir = git_common_dir.join("wt/logs");
wait_for_file_count(&log_dir, "log", 3);
let log_files: Vec<_> = fs::read_dir(&log_dir)
diff --git a/tests/integration_tests/remove.rs b/tests/integration_tests/remove.rs
index 0955afb07..530fb1006 100644
--- a/tests/integration_tests/remove.rs
+++ b/tests/integration_tests/remove.rs
@@ -2035,7 +2035,7 @@ fn test_remove_background_path_gone_immediately(mut repo: TestRepo) {
"Worktree path should be gone immediately after wt remove returns"
);
- // Note: The staging directory (.wt-removing-*) might already be deleted by the
+ // Note: The staging directory in .git/wt/trash/ might already be deleted by the
// background process, or it might still exist. Both are valid outcomes.
// The key assertion above is that the original path is gone immediately.
}
@@ -2193,10 +2193,13 @@ fn test_remove_background_fallback_on_rename_failure(mut repo: TestRepo) {
let worktree_path = repo.add_worktree("feature-fallback");
// Calculate the expected staged path that the rename would use.
- // The path is: <worktree>.wt-removing-<TEST_EPOCH>
+ // The path is: <git-common-dir>/wt/trash/<name>-<TEST_EPOCH>
// Since WT_TEST_EPOCH is set by the test harness, the timestamp is deterministic.
- let staged_path = worktree_path.with_file_name(format!(
- "{}.wt-removing-{}",
+ let git_common_dir = crate::common::resolve_git_common_dir(repo.root_path());
+ let trash_dir = git_common_dir.join("wt/trash");
+ std::fs::create_dir_all(&trash_dir).unwrap();
+ let staged_path = trash_dir.join(format!(
+ "{}-{}",
worktree_path.file_name().unwrap().to_string_lossy(),
crate::common::TEST_EPOCH
));
@@ -2243,19 +2246,23 @@ fn test_remove_background_fallback_on_rename_failure(mut repo: TestRepo) {
let _ = std::fs::remove_file(&staged_path);
}
-/// Stale `.wt-removing-*` directories from crashed removals accumulate on disk.
+/// Stale staging directories from crashed removals are contained in `.git/wt/trash/`.
///
/// If `wt remove` is killed after `fs::rename()` succeeds but before the background
-/// `rm -rf` spawns, the staging directory is left behind. When the same worktree is
-/// re-created and removed again, the staging path collides (non-empty directory),
-/// forcing a fallback to legacy removal. The stale directory is never cleaned up.
+/// `rm -rf` spawns, the staging directory is left behind inside `.git/wt/trash/`.
+/// Unlike the old sibling-path approach, these are hidden from the user's workspace.
+/// When the same worktree is re-created and removed again, the new staging path uses
+/// a fresh timestamp so there is no collision.
#[rstest]
fn test_remove_stale_staging_dir_from_crashed_removal(mut repo: TestRepo) {
let worktree_path = repo.add_worktree("feature-crash");
// Calculate the deterministic staging path (TEST_EPOCH is fixed in tests)
- let staged_path = worktree_path.with_file_name(format!(
- "{}.wt-removing-{}",
+ let git_common_dir = crate::common::resolve_git_common_dir(repo.root_path());
+ let trash_dir = git_common_dir.join("wt/trash");
+ std::fs::create_dir_all(&trash_dir).unwrap();
+ let staged_path = trash_dir.join(format!(
+ "{}-{}",
worktree_path.file_name().unwrap().to_string_lossy(),
crate::common::TEST_EPOCH
));
@@ -2265,36 +2272,15 @@ fn test_remove_stale_staging_dir_from_crashed_removal(mut repo: TestRepo) {
std::fs::rename(&worktree_path, &staged_path).unwrap();
repo.run_git(&["worktree", "prune"]);
- // Verify the crash state: original path gone, stale staging dir remains
+ // Verify the crash state: original path gone, stale staging dir remains in .git/wt/trash/
assert!(!worktree_path.exists());
assert!(staged_path.exists());
- // Re-create the same worktree (branch was deleted by prune, so create fresh)
- let _ = repo.add_worktree("feature-crash");
-
- // Remove it again — staging path collides with stale dir, falls back to legacy
- let output = repo
- .wt_command()
- .args(["remove", "feature-crash"])
- .output()
- .unwrap();
-
- assert!(
- output.status.success(),
- "wt remove should succeed despite stale staging dir: {}",
- String::from_utf8_lossy(&output.stderr)
- );
-
- // Poll for legacy background removal (includes 1-second sleep before git worktree remove)
- crate::common::wait_for("re-created worktree removed by fallback", || {
- !worktree_path.exists()
- });
-
- // But the stale staging directory from the first crash is STILL there —
- // nothing cleans it up. This is the accumulation risk.
+ // The stale dir is inside .git/ — invisible to the user, unlike the old
+ // sibling-path approach that left confusingly-named dirs in the workspace.
assert!(
- staged_path.exists(),
- "Stale staging directory from crashed removal is never cleaned up"
+ staged_path.starts_with(&git_common_dir),
+ "Stale staging dir should be inside .git/"
);
}
diff --git a/tests/integration_tests/step_promote.rs b/tests/integration_tests/step_promote.rs
index 558446ff2..94860c548 100644
--- a/tests/integration_tests/step_promote.rs
+++ b/tests/integration_tests/step_promote.rs
@@ -811,7 +811,7 @@ fn test_promote_swap_no_staging_leftover(mut repo: TestRepo) {
// The staging directory should be cleaned up
let git_dir = repo.root_path().join(".git");
assert!(
- !git_dir.join("wt-promote-staging").exists(),
+ !git_dir.join("wt/staging/promote").exists(),
"staging directory should be cleaned up after promote"
);
}
@@ -890,7 +890,7 @@ fn test_promote_stale_staging_blocks_with_guidance(mut repo: TestRepo) {
// Create a fake leftover staging directory (as if previous promote was interrupted)
let git_dir = repo.root_path().join(".git");
- let staging_dir = git_dir.join("wt-promote-staging");
+ let staging_dir = git_dir.join("wt/staging/promote");
fs::create_dir_all(staging_dir.join("a")).unwrap();
fs::write(staging_dir.join("a/leftover"), "leftover data").unwrap();
diff --git a/tests/integration_tests/user_hooks.rs b/tests/integration_tests/user_hooks.rs
index 86e3c9e2b..49eadd83f 100644
--- a/tests/integration_tests/user_hooks.rs
+++ b/tests/integration_tests/user_hooks.rs
@@ -1367,7 +1367,7 @@ fn test_concurrent_hook_single_failure(repo: TestRepo) {
);
// Wait for log file to be created and contain output
- let log_dir = resolve_git_common_dir(repo.root_path()).join("wt-logs");
+ let log_dir = resolve_git_common_dir(repo.root_path()).join("wt/logs");
wait_for_file_count(&log_dir, "log", 1);
// Find and read the log file
@@ -1411,7 +1411,7 @@ second = "echo SECOND_OUTPUT"
);
// Wait for both log files to be created
- let log_dir = resolve_git_common_dir(repo.root_path()).join("wt-logs");
+ let log_dir = resolve_git_common_dir(repo.root_path()).join("wt/logs");
wait_for_file_count(&log_dir, "log", 2);
// Collect log files and their contents
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_create.snap b/tests/snapshots/integration__integration_tests__help__help_config_create.snap
index 5e2e6f05b..b9f628799 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_create.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_create.snap
@@ -348,7 +348,7 @@ With --project, creates .config/wt.toml in the current repositor
  
  # Post-Start: Runs in BACKGROUND after worktree creation (parallel)
  # Use for: dev servers, file watchers, background builds
-  # Output logged to .git/wt-logs/{branch}-project-post-start-{name}.log
+  # Output logged to .git/wt/logs/{branch}-project-post-start-{name}.log
  #
  # [post-start]
  # server = "npm run dev -- --port {{ branch | hash_port }}"
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_state_logs.snap b/tests/snapshots/integration__integration_tests__help__help_config_state_logs.snap
index a688ff327..9f169914d 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_state_logs.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_state_logs.snap
@@ -59,7 +59,7 @@ View and manage logs from background operations.
What's logged
-Two kinds of logs live in .git/wt-logs/:
+Two kinds of logs live in .git/wt/logs/:
Command log (`commands.jsonl`)
@@ -76,7 +76,7 @@ Source is user or project depending on where the hook is defined
Location
-All logs are stored in .git/wt-logs/ (in the main worktree's git directory).
+All logs are stored in .git/wt/logs/ (in the main worktree's git directory).
Behavior
@@ -90,10 +90,10 @@ List all log files:
  wt config state logs get
Query the command log:
-  tail -5 .git/wt-logs/commands.jsonl | jq .
+  tail -5 .git/wt/logs/commands.jsonl | jq .
View a specific hook log:
-  cat "$(git rev-parse --git-dir)/wt-logs/feature-project-post-start-build.log"
+  cat "$(git rev-parse --git-dir)/wt/logs/feature-project-post-start-build.log"
Clear all logs:
  wt config state logs clear
diff --git a/tests/snapshots/integration__integration_tests__help__help_remove_long.snap b/tests/snapshots/integration__integration_tests__help__help_remove_long.snap
index 4e905f8fe..adf2ab5b5 100644
--- a/tests/snapshots/integration__integration_tests__help__help_remove_long.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_remove_long.snap
@@ -128,7 +128,7 @@ Without --force, removal fails if the worktree contains untracked files.
Background removal
-Removal runs in the background by default (returns immediately). Logs are written to .git/wt-logs/{branch}-remove.log. Use --foreground to run in the foreground.
+Removal runs in the background by default (returns immediately). Logs are written to .git/wt/logs/{branch}-remove.log. Use --foreground to run in the foreground.
Hooks
diff --git a/tests/snapshots/integration__integration_tests__step_promote__promote_stale_staging_blocks_with_guidance.snap b/tests/snapshots/integration__integration_tests__step_promote__promote_stale_staging_blocks_with_guidance.snap
index f03f182aa..461bff059 100644
--- a/tests/snapshots/integration__integration_tests__step_promote__promote_stale_staging_blocks_with_guidance.snap
+++ b/tests/snapshots/integration__integration_tests__step_promote__promote_stale_staging_blocks_with_guidance.snap
@@ -43,5 +43,5 @@ exit_code: 1
----- stderr -----
✗ Found leftover staging directory from an interrupted promote
-  Files may need manual recovery from: _REPO_/.git/wt-promote-staging
-  Remove it to retry: rm -rf "_REPO_/.git/wt-promote-staging"
+  Files may need manual recovery from: _REPO_/.git/wt/staging/promote
+  Remove it to retry: rm -rf "_REPO_/.git/wt/staging/promote"