Skip to content

fix(wtree): treat Windows drive-letter --git-path output as absolute (#3101) - #3108

Closed
szsunyuan wants to merge 1 commit into
garrytan:mainfrom
szsunyuan:fix/wtree-windows-drive-paths
Closed

szsunyuan wants to merge 1 commit into
garrytan:mainfrom
szsunyuan:fix/wtree-windows-drive-paths

Conversation

@szsunyuan

@szsunyuan szsunyuan commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Why (in your own words)

On Windows, /review and /ship cannot record a review start inside a linked git worktree. gstack-review-log --start stops with cannot capture a diff review without a working-tree fingerprint, because gstack-wtree exits 1. The cause is one classification: Git for Windows answers git rev-parse --git-path index|objects with a drive-letter absolute path (C:/…) wherever that path is absolute. gstack-wtree only treated /… as absolute, so it glued the worktree root in front (C:/…/wt/C:/…/repo/.git/objects), and the private object directory lost the repository's objects.

Fixes #3101. The same answer shape comes from submodules and --separate-git-dir repos (checked on Linux: all three print absolute --git-path output; a main checkout prints .git/…), so those are fixed on Windows too. Not a duplicate of #3088/#3100: that is gstack-hook-check's argv spelling, a different file and mechanism.

Why this shape

This is @dmfrede's fix from the issue, verified there through a full /ship run on Windows, written in the idiom bin/gstack-hook-check:56 already uses ([A-Za-z]:[\\/]*); bin/gstack-slug:178,182 makes the same check for --git-dir/--git-common-dir. The test copies the shape of #2805's test/ship-hook-windows-paths.test.ts (same bug class: a linked worktree's --git-path answer on Windows): a real linked worktree through explicit bash, force-included in the Windows lane, plus a skipIf(win32) path-spelling simulation for Linux and macOS. CONTRIBUTING's wave rule: if two PRs fix the same thing, keep the smaller one. This is 3 files on current main, and fine to absorb into a wave.

Not followed: the issue's backslash note is covered by the same bracket rather than a second pattern.

What it does

  • bin/gstack-wtree: both case blocks treat [A-Za-z]:[\\/]* as absolute; the comment above them says why.
  • test/gstack-wtree-windows-paths.test.ts (new): a linked worktree with a private object directory must fingerprint as HEAD^{tree}. On Windows that runs against Git for Windows itself. On Linux and macOS a second case puts a git shim on PATH that answers --git-path in drive-letter form and reads GIT_ALTERNATE_OBJECT_DIRECTORIES as one entry, the way Windows git does.
  • scripts/lib/windows-curation.ts: one KNOWN_WINDOWS_SAFE entry, so the Windows lane runs the new file (the detector alone excludes it for join(ROOT, 'bin', …)).

What it deliberately does not do

  • No cygpath conversion. Exporting a /c/… path to native git.exe would lean on MSYS environment rewriting, the class of bug behind Windows + Git Bash: gstack-hook-check falsely rejects all TS-entry hooks (/c/ vs C:/ join mismatch from MSYS argv translation); setup exits 1 #3088; gstack-review-log and gstack-review-read already hand native git the C:/… form (cygpath -m).
  • No --path-format=absolute. It would remove the classification, but it changes every platform's code path and needs git 2.31+; this keeps POSIX byte-for-byte as it was.
  • No change to the : join for GIT_ALTERNATE_OBJECT_DIRECTORIES (gstack-wtree:70, gstack-review-log:55). Windows git splits that list on ;, which only matters when the caller already exported the variable; filed as found-and-left-alone below.
  • No change to gstack-review-log, gstack-evidence, gstack-review-read or any skill template; no regenerated files.
  • VERSION / CHANGELOG / README / ETHOS untouched; /ship not run (the wave stamps the version).

AI was used for assistance.

Live evidence

Isolation: a temp repo with a linked worktree, a temp GSTACK_HOME, and the test's Git-for-Windows git shim first on PATH (it answers --git-path as C: + the real absolute path). No Windows machine here; see "Did NOT test".

Before (upstream/main at 20eb6202f):

$ bun test test/gstack-wtree-windows-paths.test.ts
(fail) a drive-letter --git-path answer is not re-rooted under the worktree (#3101)
 1 pass
 1 fail
$ cd <linked worktree> && PATH=<shim>:$PATH gstack-review-log --start review
error: cannot capture a diff review without a working-tree fingerprint
exit=1

After (this branch, ad6dd94ff):

$ bun test test/gstack-wtree-windows-paths.test.ts
 2 pass
 0 fail
$ cd <linked worktree> && PATH=<shim>:$PATH gstack-review-log --start review
a22f5684-704b-4764-9af3-14bd5fec87b8
exit=0

Scope

  • Changed: bin/gstack-wtree (+5/−3), test/gstack-wtree-windows-paths.test.ts (+88, new), scripts/lib/windows-curation.ts (+1). No VERSION, no CHANGELOG, no generated files.
  • Verified live by:
    • New test red on tip, green on the branch (above).
    • Mutations: dropping the objects half, or both halves, fails the test. Dropping only the index half survives by design: that half restores the stat-cache fast path, and the read-tree HEAD fallback it otherwise takes prints the identical hash (the script's own comment, lines 16-22).
    • Neighbouring suites: review-log, review-start-evidence, ship-hook-windows-paths, shared-libs-source-reads, evidence, binding-template-drift, land-and-deploy-flow, ship-plan-completion-invariants, test-free-shards, windows-native-workflows, spawnsync-timeout-tripwire: 262 pass, 0 fail.
    • bun run typecheck clean; bun run typecheck:test: "865 known diagnostics, none new".
    • Full bun run test is not green on this Linux box, on upstream/main either: Chromium cannot launch here, there is no Xvfb, and the /cso suites expect Docker and compiled scanners. The concurrent run's failures sit in 51 browse and /cso files, none of which references gstack-wtree or windows-curation. Re-running exactly those 51 files fails the same 119 tests, name for name, on upstream/main (these three files stashed) and on this branch. CI's Linux free suite is the gate.
    • bin/gstack-redact --repo-visibility public on the diff: no findings. slop-scan 0.3.0 on upstream/main and on this branch: 620 findings each; the changed files carry only the pre-existing defensive.error-obscuring at windows-curation.ts:392, which this diff does not touch.
  • Did NOT test: native Windows (no machine). The reporter verified this exact change there; the first test case runs against Git for Windows in this PR's Windows Free Tests job.

Found and left alone: the :-joined GIT_ALTERNATE_OBJECT_DIRECTORIES above (Windows splits on ;); gstack-hook-check:219 classifies bun's metafile inputs with /*|../*, which belongs to #3088. bun run slop:diff prints "slop-scan returned invalid JSON" here: through spawnSync the 2.4 MB report comes back cut off at 219 KB, so I ran slop-scan directly on both trees instead.

Liveness proof (required for external contributors)

image

Checklist

Test plan

  • bun test test/gstack-wtree-windows-paths.test.ts: red on upstream/main, green here
  • Neighbouring suites and typecheck gates (above)
  • Full bun run test: the same 119 environment failures as upstream/main, none new
  • Windows Free Tests on this PR runs the real linked-worktree case on windows-latest

Fork PRs do not get eval secrets; the free file above is the gate.

Fixes #3101

…arrytan#3101)

In a linked worktree, a submodule or a --separate-git-dir repo, git answers
--git-path with an absolute path, and Git for Windows writes it as C:/...
gstack-wtree only treated /... as absolute, so it re-rooted that path under
the worktree. With a private object directory (gstack-review-log --start)
the repository's objects went missing, the fingerprint was empty, and
/review and /ship could not record a review start. Without one, the index
copy silently fell back to the slower read-tree seed.

Accept [A-Za-z]:[\/]... as absolute in both case blocks, the idiom
gstack-hook-check already uses and the check gstack-slug already makes for
--git-common-dir. The new test runs a real linked worktree through explicit
bash, so the Windows lane exercises Git for Windows itself, and on Linux and
macOS reproduces the drive-letter answer with a git shim.

Fixes garrytan#3101

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trunk-io

trunk-io Bot commented Oct 10, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@capy-ai

capy-ai Bot commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Adopted in v1.91.89.0 (e6edff0, #3140). gstack-wtree now treats a drive-letter --git-path answer as absolute, through the shared gstack_path_absolute helper. Your test and curation entry landed as they were. Your review on #3140 also caught the symlinked-root gap and the Kiro in-place case, and both are now fixed with tests. You're credited as co-author. Thanks @szsunyuan, and @dmfrede for the fix in #3101.

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.

gstack-wtree fails in a linked git worktree on Windows (drive-letter --git-path treated as relative)

1 participant