From ef73406a966a83a486b4344f5e79de06e47ab3b1 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 29 Jun 2026 07:54:02 +0200 Subject: [PATCH] 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) --- docs-master/Config.md | 8 ++++++++ pkg/config/user_config.go | 11 +++++++++++ schema-master/config.json | 15 +++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/docs-master/Config.md b/docs-master/Config.md index 5e57df34a..183a0c6b2 100644 --- a/docs-master/Config.md +++ b/docs-master/Config.md @@ -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' diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index 1b582c1a0..844ef32bd 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -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, diff --git a/schema-master/config.json b/schema-master/config.json index 85246d640..9963aae61 100644 --- a/schema-master/config.json +++ b/schema-master/config.json @@ -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" } } }