Add worktree.defaultPath config

The redesigned worktree-creation flow never asks the user to type a path
from scratch; instead it offers candidate parent directories. Until a repo
has any linked worktrees to learn from, there's nothing to offer, so let
users seed that list with a configured default location.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Stefan Haller 2026-06-29 07:54:02 +02:00
parent 16d773fa40
commit ef73406a96
3 changed files with 34 additions and 0 deletions

View file

@ -527,6 +527,14 @@ git:
# to 40 to disable truncation.
truncateCopiedCommitHashesTo: 12
# Config relating to git worktrees
worktree:
# Default parent directory for new worktrees. It is offered as a candidate
# location alongside the parent directories of any worktrees you already have.
# A relative path is resolved against the repository's root directory, so
# "../worktrees" sits beside the repo and ".worktrees" sits inside it.
defaultPath: ""
# Periodic update checks
update:
# One of: 'prompt' (default) | 'background' | 'never'

View file

@ -11,6 +11,8 @@ type UserConfig struct {
Gui GuiConfig `yaml:"gui"`
// Config relating to git
Git GitConfig `yaml:"git"`
// Config relating to git worktrees
Worktree WorktreeConfig `yaml:"worktree"`
// Periodic update checks
Update UpdateConfig `yaml:"update"`
// Background refreshes
@ -422,6 +424,12 @@ type CommitPrefixConfig struct {
Replace string `yaml:"replace" jsonschema:"example=[$1]"`
}
type WorktreeConfig struct {
// Default parent directory for new worktrees. It is offered as a candidate location alongside the parent directories of any worktrees you already have.
// A relative path is resolved against the repository's root directory, so "../worktrees" sits beside the repo and ".worktrees" sits inside it.
DefaultPath string `yaml:"defaultPath"`
}
type UpdateConfig struct {
// One of: 'prompt' (default) | 'background' | 'never'
Method string `yaml:"method" jsonschema:"enum=prompt,enum=background,enum=never"`
@ -959,6 +967,9 @@ func GetDefaultConfigForPlatform(platform string) *UserConfig {
ParseEmoji: false,
TruncateCopiedCommitHashesTo: 12,
},
Worktree: WorktreeConfig{
DefaultPath: "",
},
Refresher: RefresherConfig{
RefreshInterval: 10,
FetchInterval: 60,

View file

@ -3834,6 +3834,10 @@
"$ref": "#/$defs/GitConfig",
"description": "Config relating to git"
},
"worktree": {
"$ref": "#/$defs/WorktreeConfig",
"description": "Config relating to git worktrees"
},
"update": {
"$ref": "#/$defs/UpdateConfig",
"description": "Periodic update checks"
@ -3899,6 +3903,17 @@
},
"additionalProperties": false,
"type": "object"
},
"WorktreeConfig": {
"properties": {
"defaultPath": {
"type": "string",
"description": "Default parent directory for new worktrees. It is offered as a candidate location alongside the parent directories of any worktrees you already have.\nA relative path is resolved against the repository's root directory, so \"../worktrees\" sits beside the repo and \".worktrees\" sits inside it."
}
},
"additionalProperties": false,
"type": "object",
"description": "Config relating to git worktrees"
}
}
}