fix(desktop): use --no-track instead of ^{commit} in v1 createWorktree#3548
fix(desktop): use --no-track instead of ^{commit} in v1 createWorktree#3548
Conversation
v1's createWorktree appended ^{commit} to the start point to prevent
implicit upstream tracking. This fails with "fatal: invalid reference"
when the ref isn't locally resolvable with that suffix (e.g. stale or
missing remote-tracking ref, branches with slashes like
feat/workstreams-view).
Replace ^{commit} with --no-track, which has the same effect without
fragile ref suffix manipulation. Matches v2's host-service approach.
Closes #3448
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughUpdated Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR fixes a
Confidence Score: 5/5Safe to merge — targeted, well-tested fix with no broader regressions expected. The change is minimal and correct: replacing an unreliable ref-syntax hack ( No files require special attention.
|
| Filename | Overview |
|---|---|
| apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts | Replaced startPoint^{commit} with --no-track flag in createWorktree; fix is targeted, correct, and consistent with the v2 flow. No other functions changed. |
| apps/desktop/src/lib/trpc/routers/workspaces/utils/git.test.ts | Two new regression tests added to the createWorktree hook tolerance suite — one for origin/main as start point and one for slash-containing branch names; both properly validate the --no-track behavior. |
Sequence Diagram
sequenceDiagram
participant C as Caller
participant CW as createWorktree()
participant EWA as execWorktreeAdd()
participant Git as git worktree add
C->>CW: branch, worktreePath, startPoint
Note over CW: OLD (broken)
CW->>EWA: args=[..., "-b", branch, worktreePath, "startPoint^{commit}"]
EWA->>Git: git worktree add -b branch path startPoint^{commit}
Git-->>EWA: fatal: invalid reference (stale ref / slash branch)
Note over CW: NEW (this PR)
CW->>EWA: args=["--no-track", "-b", branch, worktreePath, startPoint]
EWA->>Git: git worktree add --no-track -b branch path startPoint
Git-->>EWA: worktree created, no upstream tracking set
EWA-->>CW: success
CW->>Git: git config --local push.autoSetupRemote true
Note over Git: First git push will auto-set upstream
CW-->>C: resolved
Reviews (1): Last reviewed commit: "fix(desktop): use --no-track instead of ..." | Re-trigger Greptile
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/desktop/src/lib/trpc/routers/workspaces/utils/git.test.ts">
<violation number="1" location="apps/desktop/src/lib/trpc/routers/workspaces/utils/git.test.ts:445">
P2: These regression tests don’t reproduce the old `^{commit}` failure, so they won’t catch a reintroduction of the bug.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| @@ -441,6 +441,89 @@ describe("createWorktree hook tolerance", () => { | |||
| createWorktree(repoPath, "feature/existing-path", worktreePath, "HEAD"), | |||
There was a problem hiding this comment.
P2: These regression tests don’t reproduce the old ^{commit} failure, so they won’t catch a reintroduction of the bug.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/desktop/src/lib/trpc/routers/workspaces/utils/git.test.ts, line 445:
<comment>These regression tests don’t reproduce the old `^{commit}` failure, so they won’t catch a reintroduction of the bug.</comment>
<file context>
@@ -441,6 +441,89 @@ describe("createWorktree hook tolerance", () => {
).rejects.toThrow("already exists");
}, 10_000);
+
+ test("works with remote-tracking ref as start point (no-track prevents upstream)", async () => {
+ // Set up a "remote" repo with a commit, then clone it so we have origin/<branch> refs
+ const originPath = join(TEST_DIR, "worktree-notrack-origin");
</file context>
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Summary
createWorktreeappended^{commit}to the start point to suppress upstream tracking. Git rejects this withfatal: invalid referencewhen the ref isn't locally resolvable with that suffix (stale/missing remote-tracking ref, slash-containing branch names likefeat/workstreams-view).--no-trackflag — same intent, no ref parsing pitfall. Matches v2's host-service flow, which has always used--no-track.origin/mainas start point and a slash-containing branch (the exact Workspace setup failed #3448 repro).Closes #3448
Test plan
bun test apps/desktop/src/lib/trpc/routers/workspaces/utils/git.test.ts— 33 pass, including the two new casesbun run typecheckinapps/desktop— cleanbun run linton the changed files — cleanSummary by cubic
Switch v1
createWorktreeto use--no-trackinstead of appending^{commit}to the start point to disable upstream tracking. This prevents invalid ref errors from remote refs and slash-named branches and matches v2 behavior; fixes #3448.--no-trackwithgit worktree add -b <branch>, passingworktreePathandstartPointdirectly (no^{commit}).origin/mainand branches likefeat/workstreams-view.Written for commit 4e248e1. Summary will update on new commits.
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests