Commit Graph
9 Commits
Author SHA1 Message Date
stallenlu 9789f48695 fix(git): run git inside the distribution for a \wsl.localhost workspace
The git binary on the Windows PATH is a Windows build. Pointed at a
`\wsl.localhost\<distro>\…` worktree it reaches every file through the 9P
file server, one `stat` per worktree file. Measured on a 3 102-file
repository: `git status` did not finish in 180 s, `git diff --numstat`
did not finish in 25 s — while the SAME argv inside the distribution
answered in 0.47 s. The panel retried on timeout, and each retry left an
orphaned `git.exe` behind, so the source-control tab never loaded.

`spawnGit` now reads the distribution and POSIX path out of a UNC cwd
(`wslLaunch`, accepting `\wsl.localhost\`, the legacy `\wsl$\` share and
the forward-slash spelling) and, for those cwds only, launches
`wsl.exe -d <distro> --cd <path> -e git …` with the `-C <cwd>` prefix
replaced by `--cd`. `-e`, not `--`: the `--` form re-parses the tail as a
shell command line, which mangles `%(refname:short)` and anything else
carrying `()`/`[]`. `WSLENV` carries `LC_ALL`/`GIT_OPTIONAL_LOCKS` across
the boundary, which wsl.exe otherwise drops.

Everything else is untouched and shares one code path: the timeout, the
stdout/stderr byte caps, the NUL field cap, `killTree()` (which reaps the
distribution-side process too), the error strings and the
dubious-ownership retry. A non-UNC cwd spawns exactly the argv it always
did.
2026-11-05 22:28:56 +08:00
Menghuan1918 f132c69cb0 merge pr-827 (#827 fix(git): 自动应答 dubious ownership 守卫,单命令注入 safe.directory) into dev(@yanzhaohui1999)
冲突解决:保留 dev 的 runGit 三道护栏(8 MiB 输出上限 / maxNulFields 行数上限 / core.quotePath=false),
把 #827 的 spawnGit + safe.directory 重试叠在其上;GIT_ENV 取并集(GIT_OPTIONAL_LOCKS=0 + LC_ALL=C)。
不复活已被 ebc5d0b6 删除的 runGitRaw(无调用者)。
2026-10-16 16:33:38 +08:00
Menghuan1918 a628bdd1e9 fix(git): 行数封顶后不再累加输出 + 用注入式子进程确定性钉住两道上限
CI 在 ubuntu 上抓到 new 用例红:`stops producing once the NUL field cap is reached`
断言 2500 < 2500 不成立。查下来是**产品语义与断言不符**,不只是测试问题:

- `runGit` 在 `fieldCapped` 置位并 kill 子进程之后,仍然继续把后续 chunk 累加进
  `stdout`。子进程早已把整份输出写进管道时(125 KB 的 status 在 CI 上就是如此),
  被「封顶」的调用会原样返回全部 2500 行——「封顶」只约束了 kill,没有约束调用方
  拿到的东西。现在置位后忽略后续 chunk,保留量真正有界(封顶值 + 至多一个跨越
  封顶的 chunk)。
- 真 git 那条用例的 `toBeLessThan` 本质是竞态(kill 与子进程写完谁先到),把文件名
  加长到「一个 64 KiB chunk 至多携带约 500 个字段」让上界成立,并在注释里写明这条
  推理;**kill 本身**改由 `tests/git-spawn.spec.ts` 的注入式子进程确定性钉住
  (跨过封顶的 chunk + 封顶之后才到达的尾巴 + kill 恰好一次),另补字节上限的
  rejects 用例。撤掉产品守卫该用例当场红(kill 被调两次且尾巴进了结果)。

本地门禁:typecheck / lint 干净,全量 210 文件 / 2524 通过。
2026-10-16 00:28:41 +08:00
ymac cf9e1c2999 test(git): follow dev's core.quotePath=false into the argv assertions
dev added `-c core.quotePath=false` to every git invocation, which shifts
both pinned argv shapes and makes the positional `slice(5, 7)` in the
cwd-fallback case read the wrong pair. Name the flag set instead of counting
positions — the file's own subcommandOf() comment already says counting
breaks on every added `-c`.
2026-10-05 10:06:43 +08:00
ymac 31e5a78e40 Merge remote-tracking branch 'origin/dev' into fix/git-dubious-ownership
# Conflicts:
#	src/git.ts
2026-10-05 09:45:16 +08:00
ymac c0b66e11b1 fix(git): answer the dubious-ownership guard per command (#690) 2026-10-01 22:00:36 +08:00
ymac e4b189b7b5 fix(diff): name the rows git sends without ---/+++
git emits no ---/+++ for a binary file, a pure rename and a mode-only
change, and parseUnifiedDiff only ever read paths from those two lines.
The section therefore kept oldPath/newPath === '', so DiffFiles drew a
header carrying just the binary badge and no file name (sandwiched
between two .md rows, which is exactly how it reads as if those .md files
were the binary ones), and a pure rename / mode-only change collapsed to
an empty disabled button (no path, and fileTag cannot see a rename).

Recover the paths in order of authority: ---/+++ when present, else the
section's own `rename from|to`, `Binary files A and B differ`, or the
`diff --git` header. Only the mode-only shape needs the last one: it takes
the ` b/` whose two sides name the same file, and leaves the path empty
rather than guessing. ---/+++ values also lose the TAB git appends to a
spaced path, and decodeGitPath undoes git's C-quoting so diff text from a
default-quotePath source still renders the real file name.

runGit gains `-c core.quotePath=false` for the same reason at the source:
git's default turns a space/CJK path into an octal-escaped quoted string,
which every diff surface then renders as the file name. The `-z`-framed
porcelain callers are unaffected (git never quotes NUL-framed output).

Verified against taktop_redo 8b4b933, the commit whose three .jpg rows
rendered as bare badges: all three now carry their full path, and real git
output for space/CJK paths parses with no escapes and no trailing TAB.
New tests: tests/diff-binary-row.spec.tsx (rendered rows) and the path
matrix in tests/diff-rows.spec.ts; tests/git-spawn.spec.ts now derives the
subcommand from runGit's prefix instead of counting its flags.

tests/git.spec.ts had pinned the empty path (`oldPath === ''`) as the known
behaviour of a mode/rename-only section; it now asserts the recovered paths
instead, and the binary section there asserts its own name too.
2026-09-14 00:08:38 +08:00
Kunping Wang 5d8c33832c fix(git): 兼容旧版 Git 的 worktree 列表 2026-08-29 15:31:08 +08:00
Xinchen Lee 71c5413e5c fix(git): hide spawned git windows on Windows (#301) 2026-08-22 23:11:27 +08:00