diff --git a/packages/adapter-utils/src/ssh-fixture.test.ts b/packages/adapter-utils/src/ssh-fixture.test.ts index 39d3c52515e..76168e31346 100644 --- a/packages/adapter-utils/src/ssh-fixture.test.ts +++ b/packages/adapter-utils/src/ssh-fixture.test.ts @@ -1153,6 +1153,8 @@ describe("ssh env-lab fixture", () => { expect(await git(localRepo, ["log", "-1", "--pretty=%s"])).toBe("remote update"); await expect(readFile(path.join(localRepo, "tracked.txt"), "utf8")).resolves.toBe("dirty remote\n"); + // The index follows the imported HEAD: only the remote's uncommitted edit shows, unstaged. + expect(await git(localRepo, ["diff", "--cached", "--name-status"])).toBe(""); }, SSH_FIXTURE_TEST_TIMEOUT_MS); it("propagates remote commits to the local worktree with no git remote configured (no-remote-git contract)", async () => { diff --git a/packages/adapter-utils/src/ssh.ts b/packages/adapter-utils/src/ssh.ts index 37472e8293d..798d73ef6ee 100644 --- a/packages/adapter-utils/src/ssh.ts +++ b/packages/adapter-utils/src/ssh.ts @@ -13,6 +13,7 @@ import { PROJECT_REPOSITORIES_DIR, PROJECT_REPOSITORY_STAGING_PATTERN, readSanitizedOriginRemoteUrl, + resetLocalGitIndexToHead, } from "./git-workspace-sync.js"; import type { RunProcessResult } from "./server-utils.js"; import type { DirectorySnapshot } from "./workspace-restore-merge.js"; @@ -1800,6 +1801,13 @@ async function restoreWorkspaceRootFromSsh(input: { }); } : undefined, + // integrateImportedGitHead moves the branch with update-ref, which leaves the index + // on the old tip. Reset it to HEAD as the sandbox restore does (#8595). + afterApply: importedHead + ? async () => { + await resetLocalGitIndexToHead({ localDir: input.localDir }); + } + : undefined, }); } finally { if (importedRef) {