Skip to content

Migrating from git gtr: config footgunsΒ #3454

Description

@indexzero

Howdy @max-sixty πŸ‘‹ β€” Really enjoying using wt. Your effort is much appreciated πŸ™ I was on git gtr for about a year before I switched. Now I couldn't imagine going back because wt list makes juggling a dozen worktrees obvious

The pain point has been not having git gtr's config management β€” git gtr config:

# writes to .git/config β€” local to this checkout, private, always-trusted
git gtr config add gtr.hook.postCreate "pnpm install && ./hack/oneoff.sh"

# --global writes to ~/.gitconfig β€” every repo
git gtr config add gtr.hook.postCreate "pnpm install" --global

# committed .gtrconfig β€” shared with the team, gated behind `git gtr trust`
git gtr config set gtr.copy.include "**/.env.example"

Prior art: reading the tea leaves

When it comes to configs in general, I am with you on being "very keen to keep them simple". That said this issue continues to come up, which suggests other folks are stubbing their toes like I am trying to do what git gtr makes obvious and clean

git gtr is a fairly popular runner (~1.7k stars, brew installs ~5% userbase). I cite it specifically because I noticed that it hasn't been in the conversation. The config model it uses at once robust/flexible and simple

Why not existing solutions

There are two existing solutions here:

I thought about using both but adding [projects."github.com/owner/repo"] in my user config every time I use worktrunk with a new git repo is not pragmatic for my workflow

I am currently using .config/wt.toml and I nerd sniped myself here when trying to change that default path to wt.config.toml (not possible: .config/wt.toml is hard coded today).

RFC: worktrunk.config. prefixed values in git config

# local to this checkout β€” .git/config, uncommitted, private
wt config state worktrunk.config.hook.post-start "./hack/vendor.sh && pnpm install"

# global β€” ~/.gitconfig
wt config state worktrunk.config.hook.post-start "pnpm install" --global

Why I think this still honors our shared value on being "very keen to keep them configs simple":

  • No new config source. It's git's existing surface, not a new file format. Precedence is git's own, which everyone already understands: .git/config (local) over ~/.gitconfig (global).
  • Trust stays coherent. Local config is authored by me in my own checkout β€” always trusted, same as today's user config. Committed hooks keep the approval prompt.
  • worktrunk.config.* prefix separates "state" from "config" we prefer the existing wt config state command with a conventionally prefixed key worktrunk.config.* to avoid introducing ambiguity for existing wt config state managed values
  • includeIf for free. The [projectsMatching "hasconfig:…"] ask in Better config/hook ergonomics when creating new branch with uncommitted wt.tomlΒ #650 is literally git's conditional includes β€” you inherit it at zero cost.
  • Fixes a footgun. WORKTRUNK_PROJECT_CONFIG_PATH resolves relative to CWD
    • NOT the worktree root β€” project_config_path() in src/git/repository/config.rs returns PathBuf::from(path) verbatim, while the default branch does root.join(".config").join("wt.toml"). A relative override silently no-ops from a subdirectory. Reading via git config is worktree-aware by construction.

imho this makes the .config/wt.toml and [projects.*] plumbing redundant (which strictly speaking simplifies the codebase around config management a fair amount), but that also requires releasing breaking changes, which are can often take on lives of their own.

Will 100% submit a PR for this if you think it's worth exploring. Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions