Repository navigation
test(worktree): seed orphan worktrees without git 2.42 - #1925
Open
Giraffe0129 wants to merge 1 commit into
Open
Giraffe0129 wants to merge 1 commit into
Giraffe0129 wants to merge 1 commit into
Conversation
`git worktree add --orphan` needs git 2.42, but the suite still supports git 2.39 (Tencent#1008). Seed the worktrees the way product code falls back to: detach, then check out an orphan branch; and in the hooks E2E, push one empty commit into the bare repo and branch each worktree off it. Part of Tencent#1889.
This was referenced Nov 18, 2026
Author
|
Hi @jeff-r2026 , the PR is ready and all CI checks have passed. Could you please take a look when you have time? Thanks! |
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.
Summary
The suite still supports git 2.39 (#1008), but two tests create worktrees with
git worktree add --orphan, which only exists from git 2.42 on. On git 2.39uninstall.test.tsfails with
error: unknown option 'orphan'and the hooks E2E fails ingit ... worktree add --orphan, so contributors on an older git see red tests unrelated totheir change. This reaches the same end state without that flag, the way product code already
falls back (
src/utils/branch-worktree.ts): a detached worktree pluscheckout --orphanfor theuninstall case, and one seed commit in the bare repo with a branch per worktree for the E2E.
Tests only — no product code changes.
Type of Change
Test Plan
Run on Windows 11, git 2.50, Node 24.13:
npx tsc --noEmitnpx oxlint -c .oxlintrc.jsonon the two changed filesnpx vitest run uninstall -t "side branch"it.eachvariants)npx vitest run --config vitest.e2e.config.ts hooks-project-isolation-issue373 -t "removes only the caller hook file" --retry 0hooks-project-isolation-issue373filespawnSync sh ENOENTat:225— that case shells out to POSIXsh, unrelated to this change and Windows-onlyThe assertions are unchanged, so the end state is still checked: the uninstall case still requires
the linked worktree and
.git/worktreesto be gone andteamai-learningsto be deleted or kept;the seeded orphan branch still has no parent (
git rev-list --count --max-parents=0 HEAD= 1).Not checked:
git 2.39 itself — no Docker daemon here, and downloading a portable 2.39 was blocked. The removed
worktree add --orphanis the only 2.42+ API involved; its replacements (worktree add --detach,checkout --orphan,worktree add -b <branch> <path> <commit-ish>,push HEAD:refs/heads/main)all exist long before 2.39.
Full
npm run lint— reports 26 pre-existingteamai(family-facts)errors underpackages/tool-*/src/facts.ts, none of which this PR touches (they are present at 2660cfc).Lint scoped to the changed files is clean.
npx tsc --noEmitpassesnpm run lintpassesThe test files that cover what I changed pass
Added/updated tests for the change
Runtime change (
npm run verify:world) — not needed for a tests-only changeRelated Issues
Part of #1889. Does not close it: the other four items in that issue are covered by separate PRs.
Notes for Reviewers
--orphanis the point: it is the only thing here that needs git > 2.39, and productcode avoids it the same way (
src/utils/branch-worktree.ts:793-819).bare-seed), so each worktree is onits own branch instead of an unborn HEAD. The case only needs two live bare worktrees with hook
files, and no assertion changes.
checking out the orphan branch; its follow-up commits and the kept-vs-deleted assertions are
untouched.