Repository navigation
fix: wt add makes no worktree inside the .git of a clone with a work tree - #17
Merged
Merged
Conversation
This was referenced Oct 30, 2026
Make a pasted link's worktree with wt as a library, rather than wt on the PATH
lorenzolfm/luneta#210
Merged
…tree Repo::container gave the common directory of a clone that git clone made, which is its .git. wt add then made the new worktree inside it. luneta checked core.bare with its own git call before it called the library. With GIT_DIR set, that call and the library read two different repositories, and the worktree went inside the .git of a clone anyway. Now Repo reads core.bare when it is made, from the common directory that each later call uses, and holds the container only for a bare repository. container() gives an error for a clone with a work tree, and wt add refuses it before it uses the network or changes the config.
lorenzolfm
force-pushed
the
plain-clone
branch
from
November 9, 2026 18:03
071ae40 to
48400d6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Repo::containergave the common directory of a clone thatgit clonemade, which is its.git.wt addthen made the new worktree inside it, for exampleproject/.git/feature. luneta checkscore.barewith its own git call before it calls the library (lorenzolfm/luneta#210). WithGIT_DIRset, that call and the library read two different repositories, and the worktree went inside the.gitof a clone anyway.Reporeadscore.barewhen it is made, from the common directory that each later call uses, and it keeps the container only for a bare repository.git rev-parse --is-bare-repositorygives false in a worktree of a bare repository, so it cannot tell.Repo::containerreturnsResult<&Path>. It gives an error for a clone with a work tree.cmd::add::rungets the container first, so it refuses before it uses the network, adds a remote or changes an upstream branch.Repo::atmakes aRepofrom a common directory inside the crate.discover,wt cloneand the test fixtures use it.wt deletestill goes to the git directory when the repository has no container and no worktree of the base branch.wt addrefuses a clone thatgit clonemade.wt addin a clone thatgit clonemade now fails. Before, it made the worktree inside.git. I think a refusal is right. A different choice is to make the worktree beside the work tree.Test
The four CI gates (
nix build .#wt .#wt-clippy .#wt-test .#wt-fmt) pass.cargo testruns 126 tests.git cloneand callscmd::add::run. It fails withis the .git of a clone with a work tree, and.git/featureand the branchfeatureare absent.Repo::discoverfrom it. Its container is the container of the bare repository.A manual test with the binary:
wt --repo plain add --no-fetch feat2in a clone thatgit clonemadeplain/.git/feat2is absent.GIT_DIR=plain/.git wt --repo clone/main add --no-fetch feat3, withclonein the.barelayoutplain/.git. No worktree in either.wt --repo clone/main add --no-fetch feat4clone/feat4.