Skip to content

fix(agent-manager): use explicit Git fetch refspecs - #13196

Merged
marius-kilocode merged 2 commits into
mainfrom
fix-import-pull-request-refspec-exclusion
Aug 18, 2026
Merged

fix(agent-manager): use explicit Git fetch refspecs#13196
marius-kilocode merged 2 commits into
mainfrom
fix-import-pull-request-refspec-exclusion

Conversation

@marius-kilocode

@marius-kilocode marius-kilocode commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Agent Manager uses destination-less fetches for base branches and pull request heads. In repositories whose remote fetch refspec excludes the requested branch, Git can exit successfully after updating only FETCH_HEAD, leaving the tracking ref absent and causing worktree creation to fail.

Use explicit fetch destinations for base, same-repository PR, and fork PR branches. Same-repository PR imports also create a local tracking branch from the fetched ref when the branch has not been checked out before, while preserving the existing PR-head fallback.

Fixes #13058

Comment thread packages/kilo-vscode/src/agent-manager/WorktreeManager.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

The previously reported suggestion is resolved: branch.<name>.remote/merge upstream config is now only set when the primary refs/heads/<headRefName> fetch succeeds, so a branch created via the refs/pull/<n>/head fallback no longer tracks a nonexistent remote branch. The new test exercises the real fallback path against a bare remote (primary fetch fails on the deleted source branch, pull-ref fallback succeeds) and asserts both the worktree HEAD and the absence of branch.topic.remote. No memory-leak concerns — no new listeners, timers, or unbounded state.

Files Reviewed (2 files)
  • packages/kilo-vscode/src/agent-manager/WorktreeManager.ts
  • packages/kilo-vscode/tests/unit/worktree-manager.test.ts
Previous Review Summary (commit b4c8387)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit b4c8387)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/kilo-vscode/src/agent-manager/WorktreeManager.ts 1134 Upstream config (branch.<name>.remote/merge) is set even when the refs/pull/<n>/head fallback was used, leaving the new local branch tracking a remote branch that doesn't exist on origin

The refspec fix itself looks correct: explicit +refs/heads/...:refs/remotes/... destinations with validateGitRef guarding against refspec injection, fork and same-repo PR paths are consistent, and the new tests exercise real git behavior against a restrictive fetch refspec. No memory-leak concerns — no new listeners, timers, or unbounded state beyond the pre-existing static fetch cache.

Fix these issues in Kilo Cloud

Files Reviewed (3 files)
  • .changeset/fix-pr-branch-refspec.md
  • packages/kilo-vscode/src/agent-manager/WorktreeManager.ts - 1 issue
  • packages/kilo-vscode/tests/unit/worktree-manager.test.ts

Reviewed by kimi-k3 · Input: 79.4K · Output: 5.6K · Cached: 267.1K

Review guidance: REVIEW.md from base branch main

@marius-kilocode
marius-kilocode merged commit 704577a into main Aug 18, 2026
24 checks passed
@marius-kilocode
marius-kilocode deleted the fix-import-pull-request-refspec-exclusion branch August 18, 2026 09:17
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.

"Importing" a github pull request fails if a refspec excludes the branch

2 participants