Skip to content

Conversation

@alajmo
Copy link
Owner

@alajmo alajmo commented Jan 9, 2026

Add Git worktree support to mani, allowing users to define, auto-discover, and sync worktrees alongside their project repositories.

Features

  • Worktree configuration — Define worktrees per-project in mani.yaml with path (required) and branch (optional, defaults to path basename). Worktrees can live inside or outside the parent project directory.
  • Auto-discovery — mani init detects existing worktrees via git worktree list --porcelain and includes them in the generated config.
  • Sync support — mani sync creates worktrees defined in config (tries existing branch first, then creates a new one). Worktree paths are automatically added to .gitignore.
  • Orphan cleanup — New remove_orphaned_worktrees config option and --remove-orphaned-worktrees / -w sync flag to remove worktrees that exist on disk but aren't in the config.
  • Worktree-aware discovery — FindVCSystems skips git worktree directories (detected via .git file pointing to /.git/worktrees/) so they aren't listed as separate projects.

Fixes & Improvements

  • Fixed mani init to only add root directory as project when inside a git repo
  • Fixed mani init to skip printing empty projects table when no projects found
  • Fixed .gitignore update to skip root project (. path) correctly using absolute path comparison instead of string check
  • Fixed TUI to always show Tags/Paths panes even when empty
  • Fixed TUI search/filter label showing raw color tags with default theme
  • Refactored GetValue to use strings.ToLower switch (case-insensitive), added worktrees field
  • Replaced inline pointer-to-bool patterns with core.Ptr() helper
  • Modernized for loops using range-over-int
  • Various typo fixes in help text (parallell -> parallel, gitingore -> gitignore)

Other

  • Added CLAUDE.md for development guidance
  • Added benchmarks for performance testing

alajmo and others added 9 commits January 10, 2026 14:17
- Add worktrees configuration nested under projects in mani.yaml
- Auto-detect existing worktrees during `mani init`
- Create worktrees during `mani sync` (creates branch if it doesn't exist)
- Display worktrees in `mani list projects` and `mani describe projects`
- Support default path (<project>/<branch>) and custom relative paths

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Always display Tags and Paths panes in ContextView regardless of item count
- Always include Tags and Paths panes in focusable list
- Add fallback in FocusNext/FocusPrevious to prevent panic when current
  focus is not in focusable list (e.g., clicking on empty pane then Tab)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix MergeThemeOptions to convert default values (empty bg to "-",
  "bold" to "b") so color tags parse correctly in InputField
- Add worktree path validation (path is required)
- Add worktrees to .gitignore
- Add --remove-orphaned-worktrees flag to mani sync
- Improve mani init to discover worktrees using git worktree list
- Update documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use Go 1.22+ range over int syntax for cleaner loops.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove verbose feature list from CLI help
- Add documentation and issue tracker links to help output
- Simplify README description

Addresses #118

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When running `mani init`, only add the current directory as a project
with `path: .` if it IS a git repository. If not inside a git repo,
there's no point adding it as a project - only discovered subdirectory
repos will be included.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When mani init doesn't add any projects (e.g., outside a git repo),
avoid printing an empty table by returning early from PrintProjectInit.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
benchstat requires multiple samples to calculate confidence intervals
and detect meaningful differences between benchmark runs.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@alajmo alajmo force-pushed the feat/worktree-support branch from a2da149 to d9f4228 Compare January 10, 2026 13:18
Samir Alajmovic and others added 10 commits January 10, 2026 14:21
- Simplify GetValue switch statements in project, tag, and task to use
  strings.ToLower() for case-insensitive matching with explicit default
- Replace verbose pointer initialization with core.Ptr() helper in config
- Rename "worktrees" header to "worktree" for consistency
- Handle empty worktree list in project GetValue

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove duplicated comment in IsGitWorktree
- Deduplicate GetWorktrees to delegate to core.GetWorktreeList
- Allow worktree sync for local projects without a URL
- Skip uncloned projects gracefully instead of erroring during worktree sync
- Check all remotes for branch existence instead of hardcoding "origin"
- Surface YAML decode errors in ParseWorktrees instead of silently skipping
- Fix GetWdRemoteURL to use its path parameter instead of os.Getwd()
- Use structured error types for worktree operations
Fix printKeyValue dropping prefix in non-colorized output, fix root
project gitignore skip using resolved absolute path instead of dead "."
check, remove buggy CheckRemoteBranchExists (wrong git ls-remote args),
simplify IsGitWorktree return signature, simplify SyncWorktrees branch
creation with try-then-fallback, add worktree auto-discovery for root
project in InitMani, clean worktree paths with filepath.Clean, handle
detached HEAD worktrees in GetWorktreeList, show path:branch in worktree
GetValue output, add Short description to root command, fix typos in
sync examples.
When a worktree directory is manually deleted, git retains metadata in
.git/worktrees/ causing subsequent `git worktree add` to fail. Run
`git worktree prune` at the start of SyncWorktrees to clean up stale
references before attempting to create worktrees.
@alajmo alajmo merged commit 3edd8dd into main Feb 10, 2026
1 check passed
@alajmo alajmo deleted the feat/worktree-support branch February 10, 2026 13:02
@alajmo alajmo restored the feat/worktree-support branch February 10, 2026 13:02
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