fix(git): git.show 路由改用仓库相对路径,修复折叠展开空白
- src/index.ts: git.show 的 path 不再经 resolveGitPath 转绝对路径——rev:path 语法只认仓库相对路径(diff 输出剥 a// b/ 前缀的形态),绝对路径恒 fatal 返 null,折叠展开渲染空行;透传后暴露面与 git.diff/git.log 一致(仅本仓库版本树) - src/client/changes/DiffPane.tsx / src/client/DiffTab.tsx: 两侧内容皆空时抛错走「上下文未加载」降级,不再静默空白展开 背景:真机 link 测试发现展开后 marker 消失但零行渲染——git.show 路由此前无真实调用方,resolveGitPath 的工作区语义与 rev:path 树寻址不匹配的缝隙首次暴露。 设计 docs/plans/2026-09-07-git-fold-expand-design.md 实施偏差第 8 条同提交。
This commit is contained in:
+7
-1
@@ -474,7 +474,13 @@ function buildApi(
|
||||
'git.show': async (payload) => {
|
||||
const { cwd } = await gitCwdOf(payload)
|
||||
const repoRoot = selectedRepoOf(payload)
|
||||
const path = await resolveGitPath(cwd, requireString(payload, 'path'), repoRoot)
|
||||
// `git show <rev>:<path>` addresses the path inside the revision TREE:
|
||||
// repository-relative, exactly the unified diff's own path form (after
|
||||
// the a// b/ prefix). The absolute filesystem paths resolveGitPath
|
||||
// produces would break the rev:path syntax and fail every read, so the
|
||||
// path passes through as-is — it can only address blobs of this repo's
|
||||
// own revisions, the same surface git.diff/git.log already expose.
|
||||
const path = requireString(payload, 'path')
|
||||
const rev = requireString(payload, 'rev')
|
||||
return { content: await git.show(cwd, rev, path, repoRoot) }
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user