Skip to content

fix: the config has an entry only for a repository with a shared path - #20

Merged
lorenzolfm merged 3 commits into
mainfrom
empty-entry
Nov 1, 2026
Merged

lorenzolfm merged 3 commits into
mainfrom
empty-entry

Conversation

@lorenzolfm

Copy link
Copy Markdown
Owner

wt init wrote an entry with an empty list for each repository. My config has 16 entries, and only despesas has a path. The empty entry only told wt share and wt sync that wt init ran. wt add, wt cd, wt delete, wt prune and wt clone do not read the config, and the hook and wt ls read an empty entry as no entry.

  • wt init writes nothing to the config. wt share adds the entry with the first path.
  • Repo::is_managed reads the store, <common>/shared/, and not the config. wt init makes the store, so each repository that an older wt init set up stays managed. It returns bool now, bc it reads no config and needs no origin. luneta does not call it.
  • wt ignores an entry with an empty list when it reads the config, and it does not write one. A file from an older wt init loses its empty entries at the next wt share. wt share makes the entry before it tries each path, so a call where each path failed also wrote an empty entry before.
  • Two keys that differ only in case are refused only when both have a path. An empty entry loses nothing. My config has lorenzolfm/Floresta and lorenzolfm/floresta, both empty, and 0.3.0 refuses it, so the hook and each command that reads the config fail in each repository.
  • wt ls shows the links when the config has a path, as before. It no longer also asks is_managed, which was always true when the list had a path.
  • The README, wt --help and the fish completion no longer say that wt init makes a config entry.

wt init no longer needs origin. wt share still does, for the key.

A repository that wt init did not set up, for example a plain git clone on a new machine whose dotfiles have its entry, now gets run wt init first from wt share and wt sync. Before, wt share ran there with no hook, so a new worktree got no links.

An older wt on a different machine that shares the config reads a repository with no entry the same way: its wt share and wt sync say to run wt init. That wt init adds an empty entry again, and this wt ignores it.

Test

The four CI gates (nix build .#wt .#wt-clippy .#wt-test .#wt-fmt) pass. cargo test runs 71 tests.

  • One test reads a config with owner/Floresta = [], owner/floresta = [".env"] and owner/wt = []. It has one entry, owner/floresta with .env. Before, it was refused.
  • One test adds an empty entry with repo_mut beside an entry with a path. The file has the second one only. Before, it had both.
  • The test for two keys in a different case now gives a path to both.

A manual test with XDG_CONFIG_HOME on a copy of my config:

Case Result
wt ls in this repository, with wt 0.3.0 Refused: github.com/lorenzolfm/Floresta and github.com/lorenzolfm/floresta are the same repository
wt ls in this repository, with this branch The list of worktrees.
wt clone <path> proj The config does not change.
wt share .env in proj/main The config has the entry of proj with .env, and despesas. The 15 empty entries are gone.
wt add feature The hook makes the link of .env. wt ls gives 1/1 links for both worktrees.

wt init wrote an entry with an empty list for each repository, so the
config listed each repository and only some of them had a path. The
entry told wt share and wt sync that wt init ran. No other command read
it, and the hook and wt ls read an empty entry as no entry.

wt init now writes nothing to the config, and the store tells that it
ran. wt ignores an entry with an empty list, and it does not write one.
Two keys that differ only in case are refused only when both have a
path: an empty entry loses nothing.
wt init no longer read the key, so it made the store and the hook in a
repository with no origin. is_managed reads the store, so the hook then
failed at each new worktree, and wt sync and wt ls failed too: each one
finds the shared paths by the URL of origin.

wt init now reads the key before it writes anything. It also installs
the hook before it makes the store. A hook that wt cannot install then
leaves the repository unmanaged, and not managed with no hook.
@lorenzolfm
lorenzolfm merged commit 7149ed9 into main Nov 1, 2026
4 checks passed
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