repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

nushell: rework git worktree layout

495f09f0b61eebb84741736e60a8b714e80503e2

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (7)

git/gitconfig

Modified
186 186 [worktree]
187 187 guessRemote = true
188 - useRelativePaths = true
188 + useRelativePaths = false
190 190 # In order to have host-specific configuration, I include additional settings here.
191 191 # On each host a different file might be symlinked into '.gitconfig.include'.

nushell/modules/git.nu

Modified
1 1 # Git worktree helpers.
2 2 # Layout:
3 -# <root>/.git bare repository
4 -# <root>/<repo>.<branch> worktrees
3 +# <root>/.bare bare repository
4 +# <root>/<main> main worktree
5 +# <root>/wt/<branch> branch worktrees
6 7 const WT_REPO_NAME = "wt.repo-name"
7 8 const WT_MAIN_BRANCH = "wt.main-branch"
8 9 const WT_SOURCE_PATH = "wt.source-path"
10 11 const DOT_GIT = ".git"
11 -const WT_ROOT_SUFFIX = ".wt"
12 +const BARE_DIR = ".bare"
13 +const WT_DIR = "wt"
12 14 const DEFAULT_MAIN_BRANCH = "main"
13 15 const HEAD = "HEAD"
14 16 const REF_HEADS = "refs/heads/"
15 -const DIRTY_REFUSE = "refuse"
16 -const DIRTY_COPY = "copy"
17 -const DIRTY_MODES = ["refuse" "copy"]
18 17 const STATUS_PORCELAIN = ["status" "--porcelain=v1"]
19 18 const STAGED_PATCH = "staged.patch"
20 19 const UNSTAGED_PATCH = "unstaged.patch"
92 91 git-dir-output $git_dir ["config" $key $value] | ignore
94 +def git-config-unset [git_dir: path, key: string] {
95 + git-dir-complete $git_dir ["config" "--unset" $key] | ignore
98 +def git-dir-absolute-output [git_dir: path, args: list<string>] {
99 + git-output (["--git-dir" $git_dir "-c" "worktree.useRelativePaths=false"] | append $args)
102 +def configure-bare-layout [git_dir: path] {
103 + git-config-set $git_dir "core.bare" "true"
104 + git-config-unset $git_dir "core.worktree"
105 + git-config-set $git_dir "worktree.useRelativePaths" "false"
106 + git-config-unset $git_dir "extensions.relativeWorktrees"
95 109 # Branch name -> path-safe suffix.
96 110 def branch-slug [branch: string] {
97 111 $branch
115 129 let root = ($git_dir | path dirname)
116 - let repo = (git-config $git_dir $WT_REPO_NAME | default ($root | path basename | str replace --regex $"($WT_ROOT_SUFFIX)$" ""))
130 + let repo = (git-config $git_dir $WT_REPO_NAME | default ($root | path basename))
117 131 let main = (git-config $git_dir $WT_MAIN_BRANCH | default $DEFAULT_MAIN_BRANCH)
119 133 {root: $root, git_dir: $git_dir, repo: $repo, main: $main}
122 136 # Computed conventional worktree path for branch.
123 137 def wt-path [branch: string] {
124 138 let l = (layout)
125 - [$l.root $"($l.repo).(branch-slug $branch)"] | path join
139 + if $branch == $l.main {
140 + [$l.root (branch-slug $branch)] | path join
141 + } else {
142 + [$l.root $WT_DIR (branch-slug $branch)] | path join
128 146 def empty-worktree-record [] {
196 214 def add-worktree [git_dir: path, path: path, branch: string, base: string] {
215 + mkdir ($path | path dirname)
197 217 let args = if (branch-exists $git_dir $branch) {
198 218 ["worktree" "add" $path $branch]
199 219 } else {
200 220 ["worktree" "add" "-b" $branch $path $base]
203 - git-dir-output $git_dir $args | ignore
223 + git-dir-absolute-output $git_dir $args | ignore
206 226 # Create branch + worktree, or add existing branch.
269 289 def init-bare-layout [source: string, git_dir: path, repo: string, main: string] {
270 290 git-output ["clone" "--bare" $source $git_dir] | ignore
291 + configure-bare-layout $git_dir
271 292 git-config-set $git_dir $WT_REPO_NAME $repo
272 293 git-config-set $git_dir $WT_MAIN_BRANCH $main
287 -def selected-branch [branch: any] {
288 - if (($branch == null) or ($branch | is-empty)) { current-branch } else { $branch }
291 308 # Create fresh layout from remote/local repo URL/path.
292 309 def --env co-fresh [source: string, name?: string, branch?: string, dir?: path] {
293 310 let repo = if ($name == null) { repo-name-from $source } else { $name }
294 311 let parent = if ($dir == null) { "." } else { $dir }
295 312 let root = ([$parent $repo] | path join | path expand)
296 - let git_dir = ([$root $DOT_GIT] | path join)
313 + let git_dir = ([$root $BARE_DIR] | path join)
298 315 if ($root | path exists) {
299 316 error make {msg: $"target exists: ($root)"}
302 319 mkdir $root
303 - git-output ["clone" "--bare" $source $git_dir] | ignore
320 + mkdir ([$root $WT_DIR] | path join)
321 + init-bare-layout $source $git_dir $repo $DEFAULT_MAIN_BRANCH
305 323 let chosen_branch = (choose-fresh-branch $git_dir $branch)
306 - git-config-set $git_dir $WT_REPO_NAME $repo
307 324 git-config-set $git_dir $WT_MAIN_BRANCH $chosen_branch
309 - let worktree = ([$root $"($repo).(branch-slug $chosen_branch)"] | path join)
310 - git-dir-output $git_dir ["worktree" "add" $worktree $chosen_branch] | ignore
326 + let worktree = ([$root (branch-slug $chosen_branch)] | path join)
327 + git-dir-absolute-output $git_dir ["worktree" "add" $worktree $chosen_branch] | ignore
311 328 cd $worktree
313 330 {root: $root, worktree: $worktree, branch: $chosen_branch}
322 339 if $res.exit_code == 0 { $res.stdout | lines | length } else { 0 }
325 -def assert-dirty-mode [dirty: string] {
326 - if not ($dirty in $DIRTY_MODES) {
327 - error make {msg: $"--dirty must be one of: ($DIRTY_MODES | str join ', ')"}
328 - }
331 -def migration-plan [dirty_mode: string, name: any, branch: any] {
332 - assert-dirty-mode $dirty_mode
334 - let src = (git-output ["rev-parse" "--show-toplevel"] | path expand)
335 - let repo = if ($name == null) { $src | path basename } else { $name }
336 - let parent = ($src | path dirname)
337 - let root = ([$parent $"($repo)($WT_ROOT_SUFFIX)"] | path join | path expand)
338 - let git_dir = ([$root $DOT_GIT] | path join)
339 - let chosen_branch = (selected-branch $branch)
340 - let target = ([$root $"($repo).(branch-slug $chosen_branch)"] | path join)
341 - let status_before = (status-porcelain $src)
342 - let is_dirty = (not ($status_before | is-empty))
344 - {
345 - mode: "current-checkout"
346 - source: $src
347 - target_root: $root
348 - target_git_dir: $git_dir
349 - target_worktree: $target
350 - repo: $repo
351 - branch: $chosen_branch
352 - dirty: $is_dirty
353 - dirty_mode: $dirty_mode
354 - stashes: (stash-count $src)
355 - destructive: false
356 - status_before: $status_before
357 - }
360 342 def public-migration [plan: record] {
361 343 $plan | reject status_before
364 -def assert-migration-ready [plan: record] {
365 - if ($plan.target_root | path exists) {
366 - error make {msg: $"target exists: ($plan.target_root)"}
367 - }
346 +def migrate-stamp [] {
347 + date now | format date "%Y%m%d%H%M%S"
369 - if $plan.dirty and $plan.dirty_mode == $DIRTY_REFUSE {
370 - error make {msg: "working tree has changes; rerun with `co . --dirty copy` or commit/stash first"}
350 +def bare-common-dir [] {
351 + try {
352 + let git_dir = (git-output ["rev-parse" "--path-format=absolute" "--git-common-dir"])
353 + if (git-config-bool $git_dir "core.bare") == "true" { $git_dir } else { null }
354 + } catch { null }
357 +def is-new-layout [git_dir: path] {
358 + ($git_dir | path basename) == $BARE_DIR
361 +def migration-plan-normal [] {
362 + let source = (git-output ["rev-parse" "--show-toplevel"] | path expand)
363 + let branch = (current-branch)
364 + let repo = ($source | path basename)
365 + let parent = ($source | path dirname)
366 + let stamp = (migrate-stamp)
367 + let temp_root = ([$parent $".($repo).migrate-($stamp)"] | path join)
368 + let backup_root = ([$parent $".($repo).pre-wt-migrate-($stamp)"] | path join)
369 + let target_git_dir = ([$temp_root $BARE_DIR] | path join)
370 + let target_worktree = ([$temp_root (branch-slug $branch)] | path join)
373 + mode: "normal-checkout"
374 + source: $source
375 + temp_root: $temp_root
376 + backup_root: $backup_root
377 + final_root: $source
378 + target_git_dir: $target_git_dir
379 + target_worktree: $target_worktree
380 + final_worktree: ([$source (branch-slug $branch)] | path join)
381 + repo: $repo
382 + branch: $branch
383 + dirty: (not ((status-porcelain $source) | is-empty))
384 + stashes: (stash-count $source)
385 + status_before: (status-porcelain $source)
374 -def warn-stashes [plan: record] {
375 - if $plan.stashes > 0 {
376 - print -e $"warning: ($plan.stashes) stash(es) remain only in original checkout: ($plan.source)"
389 +def migration-plan-bare-container [git_dir: path] {
390 + let root = ($git_dir | path dirname)
391 + let repo = (git-config $git_dir $WT_REPO_NAME | default ($root | path basename))
392 + let main = (git-config $git_dir $WT_MAIN_BRANCH | default (current-branch))
393 + let current = (current-branch)
394 + let target_git_dir = ([$root $BARE_DIR] | path join)
397 + mode: (if (is-new-layout $git_dir) { "already-migrated" } else { "bare-container" })
398 + source: $root
399 + final_root: $root
400 + target_git_dir: $target_git_dir
401 + repo: $repo
402 + branch: $main
403 + current_branch: $current
404 + final_worktree: (canonical-worktree-path $root $main $current)
405 + worktrees: (parse-worktree-list (git-dir-output $git_dir ["worktree" "list" "--porcelain"]))
406 + status_before: ""
410 +def migration-plan [] {
411 + let git_dir = (bare-common-dir)
412 + if $git_dir != null { migration-plan-bare-container $git_dir } else { migration-plan-normal }
380 415 def patch-paths [tmp: path] {
381 416 {staged: ([$tmp $STAGED_PATCH] | path join), unstaged: ([$tmp $UNSTAGED_PATCH] | path join)}
433 -def create-migration-layout [plan: record] {
434 - mkdir $plan.target_root
435 - init-bare-layout $plan.source $plan.target_git_dir $plan.repo $plan.branch
468 +def create-normal-migration-layout [plan: record] {
469 + mkdir $plan.temp_root
470 + mkdir ([$plan.temp_root $WT_DIR] | path join)
471 + assert-external-ok "cp" (^cp -a ([$plan.source $DOT_GIT] | path join) $plan.target_git_dir | complete)
472 + configure-bare-layout $plan.target_git_dir
473 + git-config-set $plan.target_git_dir $WT_REPO_NAME $plan.repo
474 + git-config-set $plan.target_git_dir $WT_MAIN_BRANCH $plan.branch
436 475 remember-source $plan.target_git_dir $plan.source
437 - git-dir-output $plan.target_git_dir ["worktree" "add" $plan.target_worktree $plan.branch] | ignore
476 + git-dir-absolute-output $plan.target_git_dir ["worktree" "add" $plan.target_worktree $plan.branch] | ignore
440 -# Migrate current checkout into sibling .wt layout; original untouched.
441 -def --env co-current [name?: string, branch?: string, plan: bool = false, dirty: string = $DIRTY_REFUSE] {
442 - let migration = (migration-plan $dirty $name $branch)
443 - if $plan { return (public-migration $migration) }
479 +def --env swap-migrated-normal [plan: record] {
480 + cd ($plan.source | path dirname)
481 + mv $plan.source $plan.backup_root
482 + mv $plan.temp_root $plan.final_root
445 - assert-migration-ready $migration
446 - warn-stashes $migration
485 +def --env migrate-normal [plan: record] {
486 + if ($plan.temp_root | path exists) { error make {msg: $"target exists: ($plan.temp_root)"} }
487 + if ($plan.backup_root | path exists) { error make {msg: $"backup exists: ($plan.backup_root)"} }
448 - let tmp = if $migration.dirty { mktemp -d } else { null }
489 + let tmp = (mktemp -d)
451 - let patches = if $migration.dirty { write-dirty-patches $migration.source $tmp } else { null }
452 - create-migration-layout $migration
453 - if $migration.dirty {
454 - copy-dirty-state $migration $patches
492 + let patches = (write-dirty-patches $plan.source $tmp)
493 + create-normal-migration-layout $plan
494 + copy-dirty-state $plan $patches
495 + swap-migrated-normal $plan
496 + let final_git_dir = ([$plan.final_root $BARE_DIR] | path join)
497 + repair-bare-worktrees $final_git_dir [{path: $plan.final_worktree, bare: false}]
498 + let final_status = (status-porcelain $plan.final_worktree)
499 + if $plan.status_before != $final_status {
500 + error make {msg: $"post-swap status verification failed; backup kept at ($plan.backup_root)"}
456 - if $tmp != null { rm -rf $tmp }
502 + rm -rf $tmp
457 503 } catch {|err|
458 - if $tmp != null { rm -rf $tmp }
504 + rm -rf $tmp
459 505 error make {msg: $err.msg}
462 - cd $migration.target_worktree
463 - public-migration $migration
508 + cd $plan.final_worktree
509 + public-migration $plan
466 -# Bootstrap checkout.
512 +def repair-bare-worktrees [git_dir: path, worktrees: list<any>] {
513 + let paths = ($worktrees | where bare == false | get path)
514 + if ($paths | is-empty) {
515 + git-dir-absolute-output $git_dir ["worktree" "repair"] | ignore
516 + } else {
517 + git-dir-absolute-output $git_dir (["worktree" "repair"] | append $paths) | ignore
521 +def canonical-worktree-path [root: path, main: string, branch: string] {
522 + if $branch == $main {
523 + [$root (branch-slug $branch)] | path join
524 + } else {
525 + [$root $WT_DIR (branch-slug $branch)] | path join
529 +def move-legacy-worktrees [git_dir: path, root: path, main: string] {
530 + let rows = (parse-worktree-list (git-dir-output $git_dir ["worktree" "list" "--porcelain"]) | where bare == false | where branch != null)
531 + for row in $rows {
532 + let dest = (canonical-worktree-path $root $main $row.branch)
533 + if ($row.path | path expand) == ($dest | path expand) { continue }
534 + if ($dest | path exists) { error make {msg: $"target exists: ($dest)"} }
535 + mkdir ($dest | path dirname)
536 + git-dir-absolute-output $git_dir ["worktree" "move" $row.path $dest] | ignore
540 +def --env migrate-bare-container [plan: record] {
541 + if $plan.mode == "already-migrated" {
542 + configure-bare-layout $plan.target_git_dir
543 + mkdir ([$plan.final_root $WT_DIR] | path join)
544 + git-dir-absolute-output $plan.target_git_dir ["worktree" "repair"] | ignore
545 + cd $plan.final_worktree
546 + return (public-migration $plan)
549 + if ($plan.target_git_dir | path exists) { error make {msg: $"target exists: ($plan.target_git_dir)"} }
551 + mv ([$plan.final_root $DOT_GIT] | path join) $plan.target_git_dir
552 + configure-bare-layout $plan.target_git_dir
553 + git-config-set $plan.target_git_dir $WT_REPO_NAME $plan.repo
554 + git-config-set $plan.target_git_dir $WT_MAIN_BRANCH $plan.branch
555 + mkdir ([$plan.final_root $WT_DIR] | path join)
556 + repair-bare-worktrees $plan.target_git_dir $plan.worktrees
557 + cd $plan.final_root
558 + move-legacy-worktrees $plan.target_git_dir $plan.final_root $plan.branch
559 + cd $plan.final_worktree
560 + public-migration $plan
563 +# Bootstrap fresh checkout.
467 564 export def --env co [
468 - source: string = "." # URL/path, or `.` to migrate current checkout
565 + source: string # URL/path
469 566 name?: string # repo/root name
470 567 --branch (-b): string = "" # branch to check out; default remote/current HEAD
471 568 --dir (-d): path = "." # parent dir for fresh checkout
472 - --plan # with `co .`: preview only
473 - --dirty: string = $DIRTY_REFUSE # `refuse` | `copy`
475 570 if $source == "." {
476 - co-current $name $branch $plan $dirty
477 - } else {
478 - if $plan { error make {msg: "--plan only applies to `co .`"} }
479 - if $dirty != $DIRTY_REFUSE { error make {msg: "--dirty only applies to `co .`"} }
480 - co-fresh $source $name $branch $dir
571 + error make {msg: "use `wt migrate` to convert the current checkout"}
574 + co-fresh $source $name $branch $dir
484 577 # Summary.
603 +export def --env "wt migrate" [
604 + --dry
605 +] {
606 + let plan = (migration-plan)
607 + if $dry { return (public-migration $plan) }
609 + if $plan.mode == "normal-checkout" {
610 + migrate-normal $plan
611 + } else {
612 + migrate-bare-container $plan
510 616 export def --env "wt new" [
511 617 branch: string
512 618 --base (-b): string = $HEAD
557 663 export def "wt repair" [] {
558 - git-dir-output (layout).git_dir ["worktree" "repair"] | ignore
664 + let l = (layout)
665 + configure-bare-layout $l.git_dir
666 + git-dir-absolute-output $l.git_dir ["worktree" "repair"] | ignore
561 669 # Thin native aliases for muscle memory / git parity.

nushell/tests/git-command-coverage.sh

Added
new file mode 100755
1 +#!/usr/bin/env bash
2 +set -euo pipefail
4 +repo_root="$(git rev-parse --show-toplevel)"
5 +real_git="$(command -v git)"
6 +tmp="$(mktemp -d /tmp/dotfiles-git-coverage-XXXXXX)"
7 +trap 'rm -rf "$tmp"' EXIT
9 +log="$tmp/git.log"
10 +wrapper_dir="$tmp/bin"
11 +mkdir -p "$wrapper_dir"
13 +cat >"$wrapper_dir/git" <<'WRAP'
14 +#!/usr/bin/env bash
15 +set -euo pipefail
16 +if [ "${DOTFILES_GIT_TEST_PHASE:-}" = nu ]; then
17 + for arg in "$@"; do printf '%q ' "$arg" >>"$DOTFILES_GIT_LOG"; done
18 + printf '\n' >>"$DOTFILES_GIT_LOG"
19 +fi
20 +exec "$DOTFILES_REAL_GIT" "$@"
21 +WRAP
22 +chmod +x "$wrapper_dir/git"
24 +PATH="$wrapper_dir:$PATH" \
25 +DOTFILES_REAL_GIT="$real_git" \
26 +DOTFILES_GIT_LOG="$log" \
27 +bash "$repo_root/nushell/tests/git-worktree-layout.sh" >/tmp/dotfiles-git-coverage-smoke.log
29 +[ -s "$log" ] || { cat /tmp/dotfiles-git-coverage-smoke.log >&2; echo "FAIL: no git invocations logged" >&2; exit 1; }
31 +require() {
32 + local label="$1"
33 + local pattern="$2"
34 + if ! grep -Eq -- "$pattern" "$log"; then
35 + echo "FAIL: missing git invocation: $label" >&2
36 + echo "pattern: $pattern" >&2
37 + echo "--- smoke output ---" >&2
38 + cat /tmp/dotfiles-git-coverage-smoke.log >&2
39 + echo "--- git log ---" >&2
40 + cat "$log" >&2
41 + exit 1
42 + fi
45 +require 'rev-parse common dir' '^rev-parse --path-format=absolute --git-common-dir $'
46 +require 'rev-parse branch' '^rev-parse --abbrev-ref HEAD $'
47 +require 'rev-parse top-level' '^rev-parse --show-toplevel $'
48 +require 'clone bare' '^clone --bare .+ .+/\.bare $'
49 +require 'config get' '^--git-dir .+ config --get wt\.repo-name $'
50 +require 'config bool get' '^--git-dir .+ config --bool --get core\.bare $'
51 +require 'config set core.bare' '^--git-dir .+ config core\.bare true $'
52 +require 'config unset core.worktree' '^--git-dir .+ config --unset core\.worktree $'
53 +require 'config set relative false' '^--git-dir .+ config worktree\.useRelativePaths false $'
54 +require 'config unset relative extension' '^--git-dir .+ config --unset extensions\.relativeWorktrees $'
55 +require 'symbolic-ref default branch' '^--git-dir .+ symbolic-ref --short HEAD $'
56 +require 'worktree list' '^--git-dir .+ worktree list --porcelain $'
57 +require 'show-ref branch exists' '^--git-dir .+ show-ref --verify --quiet refs/heads/.+ $'
58 +require 'worktree add existing branch' '^--git-dir .+ -c worktree\.useRelativePaths=false worktree add [^-].+ .+ $'
59 +require 'worktree add new branch' '^--git-dir .+ -c worktree\.useRelativePaths=false worktree add -b .+ .+ .+ $'
60 +require 'worktree remove clean' '^--git-dir .+ worktree remove /.+ $'
61 +require 'worktree remove force' '^--git-dir .+ worktree remove --force /.+ $'
62 +require 'branch delete merged' '^--git-dir .+ branch -d .+ $'
63 +require 'branch delete force' '^--git-dir .+ branch -D .+ $'
64 +require 'worktree prune' '^--git-dir .+ worktree prune $'
65 +require 'worktree repair' '^--git-dir .+ -c worktree\.useRelativePaths=false worktree repair.*$'
66 +require 'worktree lock no reason' '^--git-dir .+ worktree lock /.+ $'
67 +require 'worktree lock reason' '^--git-dir .+ worktree lock --reason testing /.+ $'
68 +require 'worktree unlock' '^--git-dir .+ worktree unlock /.+ $'
69 +require 'worktree move' '^--git-dir .+ worktree move /.+ /.+ $'
70 +require 'worktree move absolute wrapper' '^--git-dir .+ -c worktree\.useRelativePaths=false worktree move /.+ /.+ $'
71 +require 'status porcelain' '^-C /.+ status --porcelain=v1 $'
72 +require 'status sanity' '^-C /.+ status $'
73 +require 'stash list' '^-C /.+ stash list $'
74 +require 'diff cached' '^-C /.+ diff --binary --cached $'
75 +require 'diff unstaged' '^-C /.+ diff --binary $'
76 +require 'apply index' '^-C /.+ apply --index /.+staged\.patch $'
77 +require 'apply unstaged' '^-C /.+ apply /.+unstaged\.patch $'
79 +printf 'ok git-command-coverage\n'

nushell/tests/git-command-verification.md

Added
new file mode 100644
1 +# Nushell git module verification matrix
3 +Primary scope: `nushell/modules/git.nu`.
5 +Secondary verified scope:
7 +- `nushell/modules/sy.nu`: dotfiles sync helper; real `run-external git` calls are verified separately.
9 +Not command modules for this goal:
11 +- `nushell/modules/prompt.nu`: parses `.git` metadata, does not invoke `git`.
12 +- `nushell/gen-aliases.nu`: defines alias metadata only (`aka g git`), no concrete git argv to verify.
14 +All verification must run in disposable temp repos/remotes via:
16 +- `nushell/tests/git-scope-guard.sh`: static guard for Nushell files that launch external `git`; prevents silently ignoring a new module/caller.
17 +- `nushell/tests/git-worktree-layout.sh`: `git.nu` behavior/effects smoke.
18 +- `nushell/tests/git-command-coverage.sh`: wraps `git` during `git.nu` Nushell calls, logs actual argv, and asserts every command shape below is exercised.
19 +- `nushell/tests/git-sync-module.sh`: `sy.nu` behavior/effects smoke with git argv logging.
21 +## Exported command coverage
23 +| Export | Class | Covered by smoke | Notes |
24 +|---|---:|---:|---|
25 +| `co` | network/local mutating | yes | local bare remote fixture only |
26 +| `wt` | read-only | yes | alias for `wt ls` |
27 +| `wt root` | read-only | yes | layout metadata |
28 +| `wt repo` | read-only | yes | layout metadata |
29 +| `wt path` | read-only | yes | canonical paths |
30 +| `wt ls` | read-only + per-worktree status | yes | checks dirty state |
31 +| `wt migrate --dry` | read-only planning | yes | normal checkout fixture |
32 +| `wt migrate` | destructive/local mutating | yes | normal + legacy fixtures; source backup verified |
33 +| `wt new` | local mutating | yes | with and without `--switch` |
34 +| `wt go` | env/local mutating with `--create` | yes | create path verified |
35 +| `wt rm` | destructive/local mutating | yes | removes worktree only |
36 +| `wt done` | destructive/local mutating | yes | removes worktree + branch |
37 +| `wt prune` | destructive metadata cleanup | yes | temp layout only |
38 +| `wt repair` | local mutating metadata | yes | forces absolute layout |
39 +| `wt add` | local mutating | yes | alias for `wt new` |
40 +| `wt list` | read-only | yes | alias for `wt ls` |
41 +| `wt lock` | local metadata mutating | yes | locks temp worktree |
42 +| `wt unlock` | local metadata mutating | yes | unlocks temp worktree |
43 +| `wt move` | local mutating | yes | path move verified |
44 +| `wt remove` | destructive/local mutating | yes | alias for `wt rm` |
46 +## `sy.nu` exported command coverage
48 +| Export | Git command shape | Class | Covered by smoke | Notes |
49 +|---|---|---:|---:|---|
50 +| `sy` / `main` | `git -C $DOTFILES status --short --branch` | read-only | yes | disposable `$DOTFILES` clone; fake `macchina` |
51 +| `sy up` | `git -C $DOTFILES add --all` | local mutating | yes | clean disposable clone |
52 +| `sy up` | `git -C $DOTFILES commit --all` | local mutating | yes | clean clone, failure tolerated by module |
53 +| `sy up` | `git -C $DOTFILES push` | remote/network mutating | yes | local bare remote only |
54 +| `sy down` | `git -C $DOTFILES pull` | remote/network mutating | yes | local bare remote only; fake `topgrade` |
56 +## `git.nu` invocation inventory
58 +| Line | Git command shape | Class | Exercised by |
59 +|---:|---|---:|---|
60 +| 32 | `git ...$args` | wrapper | all commands |
61 +| 34 | `git -C $cwd ...$args` | wrapper | status/diff/apply/stash checks |
62 +| 81 | `git --git-dir <dir> config --get <key>` | read-only | layout, migration, config checks |
63 +| 86 | `git --git-dir <dir> config --bool --get <key>` | read-only | layout detection/config checks |
64 +| 91 | `git --git-dir <dir> config <key> <value>` | local metadata mutating | `co`, `wt migrate`, `wt repair` |
65 +| 95 | `git --git-dir <dir> config --unset <key>` | local metadata mutating | `co`, `wt migrate`, `wt repair` |
66 +| 99 | `git --git-dir <dir> -c worktree.useRelativePaths=false ...` | wrapper | all worktree add/move/repair absolute-path operations |
67 +| 123 | `git rev-parse --path-format=absolute --git-common-dir` | read-only | all layout commands |
68 +| 201 | `git --git-dir <dir> worktree list --porcelain` | read-only | `wt`, `wt ls`, `wt list`, path lookup |
69 +| 211 | `git --git-dir <dir> show-ref --verify --quiet refs/heads/<branch>` | read-only | `wt new`, `wt add`, `wt go --create` |
70 +| 223 | `git worktree add [ -b ] <path> <branch/base>` | local mutating | `wt new`, `wt add`, `wt go --create` |
71 +| 241 | `git rev-parse --abbrev-ref HEAD` | read-only | current branch, migrate, default remove |
72 +| 247 | `git rev-parse --show-toplevel` | read-only | current repo top/current marker |
73 +| 271 | `git --git-dir <dir> branch -d/-D <branch>` | destructive local mutating | `wt done` |
74 +| 280 | `git --git-dir <dir> worktree remove [--force] <path>` | destructive local mutating | `wt rm`, `wt remove`, `wt done` |
75 +| 290 | `git clone --bare <source> <git_dir>` | network/local mutating | `co` with local bare fixture |
76 +| 302 | `git --git-dir <dir> symbolic-ref --short HEAD` | read-only | `co` without `--branch` |
77 +| 327 | `git worktree add <main-path> <branch>` | local mutating | `co` |
78 +| 338 | `git -C <cwd> stash list` | read-only | `wt migrate` normal checkout |
79 +| 352 | `git rev-parse --path-format=absolute --git-common-dir` | read-only | `wt migrate` layout detection |
80 +| 362 | `git rev-parse --show-toplevel` | read-only | `wt migrate` normal checkout |
81 +| 405 | `git --git-dir <dir> worktree list --porcelain` | read-only | `wt migrate` legacy container |
82 +| 421 | `git -C <source> diff --binary --cached` | read-only | dirty migration |
83 +| 422 | `git -C <source> diff --binary` | read-only | dirty migration |
84 +| 432 | `git -C <target> apply [--index] <patch>` | local mutating | dirty migration |
85 +| 449 | `git -C <source> status` | read-only sanity | dirty migration |
86 +| 476 | `git worktree add <target> <branch>` | local mutating | normal checkout migration |
87 +| 515 | `git worktree repair` | local metadata mutating | migration repair |
88 +| 517 | `git worktree repair <paths...>` | local metadata mutating | normal checkout migration |
89 +| 530 | `git worktree list --porcelain` | read-only | legacy migration |
90 +| 536 | `git worktree move <old> <new>` | local mutating | legacy migration |
91 +| 544 | `git worktree repair` | local metadata mutating | `wt migrate` on already-new layout |
92 +| 660 | `git worktree prune` | destructive metadata cleanup | `wt prune` |
93 +| 666 | `git worktree repair` | local metadata mutating | `wt repair` |
94 +| 681 | `git worktree lock [--reason] <path>` | local metadata mutating | `wt lock` |
95 +| 686 | `git worktree unlock <path>` | local metadata mutating | `wt unlock` |
96 +| 690 | `git worktree move <path> <dest>` | local mutating | `wt move` |
98 +## Failure behavior coverage
100 +| Scenario | Covered by smoke | Expected behavior |
101 +|---|---:|---|
102 +| `wt ls` outside co/wt layout | yes | fails |
103 +| `co .` | yes | fails; instructs `wt migrate` |
104 +| `wt new` to existing path/branch (`trunk`) | yes | fails |
105 +| `wt migrate` detached HEAD | yes | fails; original `.git` checkout remains |
107 +## Evidence commands
109 +Current verification set:
111 +```bash
112 +bash nushell/tests/git-scope-guard.sh
113 +bash nushell/tests/git-worktree-layout.sh
114 +bash nushell/tests/git-command-coverage.sh
115 +bash nushell/tests/git-sync-module.sh
116 +nu --commands 'use ./nushell/modules/git.nu *; help co | ignore; help wt migrate | ignore'
117 +nu --commands 'use ./nushell/modules/sy.nu; help sy | ignore; help "sy up" | ignore; help "sy down" | ignore'
118 +just check
119 +```
121 +`git-scope-guard.sh` records the exact external-git callers in `nushell/`: `nushell/modules/git.nu` and `nushell/modules/sy.nu` are verified; `nushell/gen-aliases.nu` is alias metadata only.
123 +`git-command-coverage.sh` logs only git invocations launched from `git.nu` Nushell calls (`DOTFILES_GIT_TEST_PHASE=nu`) and ignores fixture setup git commands.
125 +`git-sync-module.sh` logs only git invocations reached through `sy.nu` commands and uses fake `macchina`/`topgrade` plus a local bare remote.
127 +## Remaining verification gaps
129 +None known for exported commands and direct git invocation shapes in `nushell/modules/git.nu` or `nushell/modules/sy.nu`.

nushell/tests/git-scope-guard.sh

Added
new file mode 100755
1 +#!/usr/bin/env bash
2 +set -euo pipefail
4 +repo_root="$(git rev-parse --show-toplevel)"
5 +cd "$repo_root"
7 +actual="$(grep -RInE '(^|[[:space:]])(\^git|run-external git|aka [^[:space:]]+ git($|[[:space:]]))' nushell --include='*.nu' \
8 + | sed 's#^./##' \
9 + | sort)"
11 +expected='nushell/gen-aliases.nu:38:aka g git
12 +nushell/modules/git.nu:32: ^git ...$args | complete
13 +nushell/modules/git.nu:34: ^git -C $cwd ...$args | complete
14 +nushell/modules/git.nu:421: ^git -C $source diff --binary --cached | save --force $patches.staged
15 +nushell/modules/git.nu:422: ^git -C $source diff --binary | save --force $patches.unstaged
16 +nushell/modules/sy.nu:17: run-external git ...$git_add_dotfiles
17 +nushell/modules/sy.nu:18: try { run-external git ...$git_commit_dotfiles }
18 +nushell/modules/sy.nu:19: run-external git ...$git_push_dotfiles
19 +nushell/modules/sy.nu:26: run-external git ...$git_pull_dotfiles
20 +nushell/modules/sy.nu:5: run-external git ...$git_status_dotfiles'
22 +if [ "$actual" != "$expected" ]; then
23 + echo 'FAIL: Nushell git caller scope changed' >&2
24 + echo '--- expected ---' >&2
25 + printf '%s\n' "$expected" >&2
26 + echo '--- actual ---' >&2
27 + printf '%s\n' "$actual" >&2
28 + exit 1
29 +fi
31 +printf 'ok git-scope-guard\n'

nushell/tests/git-sync-module.sh

Added
new file mode 100755
1 +#!/usr/bin/env bash
2 +set -euo pipefail
4 +repo_root="$(git rev-parse --show-toplevel)"
5 +module="$repo_root/nushell/modules/sy.nu"
6 +real_git="$(command -v git)"
7 +tmp="$(mktemp -d /tmp/dotfiles-sy-git-test-XXXXXX)"
8 +trap 'rm -rf "$tmp"' EXIT
10 +fail() { echo "FAIL: $*" >&2; exit 1; }
12 +bin="$tmp/bin"
13 +mkdir -p "$bin"
14 +cat >"$bin/git" <<'SH'
15 +#!/usr/bin/env bash
16 +set -euo pipefail
17 +for arg in "$@"; do printf '%q ' "$arg" >>"$DOTFILES_SY_GIT_LOG"; done
18 +printf '\n' >>"$DOTFILES_SY_GIT_LOG"
19 +exec "$DOTFILES_REAL_GIT" "$@"
20 +SH
21 +cat >"$bin/macchina" <<'SH'
22 +#!/usr/bin/env bash
23 +printf 'macchina-ok\n'
24 +SH
25 +cat >"$bin/topgrade" <<'SH'
26 +#!/usr/bin/env bash
27 +printf 'topgrade-ok\n'
28 +SH
29 +chmod +x "$bin/git" "$bin/macchina" "$bin/topgrade"
30 +log="$tmp/git.log"
32 +run_nu() {
33 + PATH="$bin:$PATH" DOTFILES="$tmp/work" DOTFILES_REAL_GIT="$real_git" DOTFILES_SY_GIT_LOG="$log" nu --commands "use '$module'; $*"
36 +git init --bare "$tmp/origin.git" >/dev/null
37 +git clone "$tmp/origin.git" "$tmp/seed" >/dev/null 2>&1
38 +git -C "$tmp/seed" config user.email test@example.invalid
39 +git -C "$tmp/seed" config user.name test
40 +echo root >"$tmp/seed/root.txt"
41 +git -C "$tmp/seed" add root.txt
42 +git -C "$tmp/seed" commit -m init >/dev/null
43 +git -C "$tmp/seed" branch -M trunk
44 +git -C "$tmp/seed" push -u origin trunk >/dev/null 2>&1
45 +git --git-dir="$tmp/origin.git" symbolic-ref HEAD refs/heads/trunk
47 +git clone "$tmp/origin.git" "$tmp/work" >/dev/null 2>&1
48 +git -C "$tmp/work" config user.email test@example.invalid
49 +git -C "$tmp/work" config user.name test
51 +run_nu "sy" | grep -q 'macchina-ok' || fail 'main did not run macchina'
52 +run_nu "sy up" >/tmp/dotfiles-sy-up.log
53 +run_nu "sy down" | grep -q 'topgrade-ok' || fail 'down did not run topgrade'
55 +git -C "$tmp/work" status --short --branch >/tmp/dotfiles-sy-status.log
56 +grep -q '## trunk' /tmp/dotfiles-sy-status.log || fail 'work repo not on trunk after sy commands'
58 +require() {
59 + local label="$1"
60 + local pattern="$2"
61 + if ! grep -Eq -- "$pattern" "$log"; then
62 + echo "FAIL: missing sy git invocation: $label" >&2
63 + echo "pattern: $pattern" >&2
64 + echo "--- git log ---" >&2
65 + cat "$log" >&2
66 + exit 1
67 + fi
70 +require 'status short branch' "^-C $tmp/work status --short --branch $"
71 +require 'add all' "^-C $tmp/work add --all $"
72 +require 'commit all' "^-C $tmp/work commit --all $"
73 +require 'push' "^-C $tmp/work push $"
74 +require 'pull' "^-C $tmp/work pull $"
76 +printf 'ok git-sync-module\n'

nushell/tests/git-worktree-layout.sh

Added
new file mode 100755
1 +#!/usr/bin/env bash
2 +set -euo pipefail
4 +repo_root="$(git rev-parse --show-toplevel)"
5 +module="$repo_root/nushell/modules/git.nu"
6 +tmp="$(mktemp -d /tmp/dotfiles-wt-test-XXXXXX)"
7 +trap 'rm -rf "$tmp"' EXIT
9 +fail() { echo "FAIL: $*" >&2; exit 1; }
10 +assert_dir() { [ -d "$1" ] || fail "missing dir: $1"; }
11 +assert_file() { [ -f "$1" ] || fail "missing file: $1"; }
12 +assert_no_path() { [ ! -e "$1" ] || fail "unexpected path: $1"; }
14 +run_nu() {
15 + local cwd="$1"
16 + shift
17 + DOTFILES_GIT_TEST_PHASE=nu nu --commands "use '$module' *; cd '$cwd'; $*"
20 +expect_fail() {
21 + local cwd="$1"
22 + shift
23 + if run_nu "$cwd" "$*" >/tmp/dotfiles-wt-unexpected-success.log 2>&1; then
24 + cat /tmp/dotfiles-wt-unexpected-success.log >&2
25 + fail "expected failure: $*"
26 + fi
29 +expected_exports='co
30 +wt
31 +wt add
32 +wt done
33 +wt go
34 +wt list
35 +wt lock
36 +wt ls
37 +wt migrate
38 +wt move
39 +wt new
40 +wt path
41 +wt prune
42 +wt remove
43 +wt repair
44 +wt repo
45 +wt rm
46 +wt root
47 +wt unlock'
48 +actual_exports="$(perl -ne 'if (/^export def(?: --env)? (?:"([^"]+)"|([^\s\[]+))/) { print (($1 // $2) . "\n") }' "$module" | sort)"
49 +[ "$actual_exports" = "$expected_exports" ] || fail "exported command list mismatch
50 +expected:
51 +$expected_exports
52 +actual:
53 +$actual_exports"
55 +mkdir -p "$tmp/src" "$tmp/ws"
56 +git init --bare "$tmp/origin.git" >/dev/null
57 +git clone "$tmp/origin.git" "$tmp/src" >/dev/null 2>&1
58 +git -C "$tmp/src" config user.email test@example.invalid
59 +git -C "$tmp/src" config user.name test
60 +echo root > "$tmp/src/root.txt"
61 +git -C "$tmp/src" add root.txt
62 +git -C "$tmp/src" commit -m init >/dev/null
63 +git -C "$tmp/src" branch -M trunk
64 +git -C "$tmp/src" push -u origin trunk >/dev/null 2>&1
65 +git --git-dir="$tmp/origin.git" symbolic-ref HEAD refs/heads/trunk
67 +run_nu "$tmp/ws" "co '$tmp/origin.git' default-demo --dir '$tmp/ws' | ignore"
68 +assert_dir "$tmp/ws/default-demo/.bare"
69 +assert_dir "$tmp/ws/default-demo/trunk"
70 +git -C "$tmp/ws/default-demo/trunk" status --short --branch >/dev/null
72 +run_nu "$tmp/ws" "co '$tmp/origin.git' demo --branch trunk --dir '$tmp/ws' | ignore"
74 +assert_dir "$tmp/ws/demo/.bare"
75 +assert_dir "$tmp/ws/demo/trunk"
76 +assert_dir "$tmp/ws/demo/wt"
77 +assert_file "$tmp/ws/demo/trunk/.git"
78 +assert_no_path "$tmp/ws/demo/.git"
79 +assert_no_path "$tmp/ws/demo/demo.trunk"
81 +gitfile="$(cat "$tmp/ws/demo/trunk/.git")"
82 +[[ "$gitfile" == "gitdir: $tmp/ws/demo/.bare/worktrees/"* ]] || fail "gitfile not absolute .bare path: $gitfile"
83 +[ "$(git --git-dir="$tmp/ws/demo/.bare" config --bool core.bare)" = true ] || fail ".bare not bare"
84 +[ -z "$(git --git-dir="$tmp/ws/demo/.bare" config --get extensions.relativeWorktrees || true)" ] || fail "relativeWorktrees set"
85 +[ "$(git --git-dir="$tmp/ws/demo/.bare" config --bool worktree.useRelativePaths)" = false ] || fail "useRelativePaths not false"
87 +git -C "$tmp/ws/demo/trunk" status --short --branch >/dev/null
88 +[ "$(run_nu "$tmp/ws/demo/trunk" "wt root")" = "$tmp/ws/demo" ] || fail "wt root mismatch"
89 +[ "$(run_nu "$tmp/ws/demo/trunk" "wt repo")" = "demo" ] || fail "wt repo mismatch"
90 +[ "$(run_nu "$tmp/ws/demo/trunk" "wt path trunk")" = "$tmp/ws/demo/trunk" ] || fail "wt path trunk mismatch"
91 +run_nu "$tmp/ws/demo/trunk" "wt | ignore"
92 +run_nu "$tmp/ws/demo/trunk" "wt ls | ignore"
93 +run_nu "$tmp/ws/demo/trunk" "wt list | ignore"
94 +run_nu "$tmp/ws/demo/trunk" "wt repair"
95 +run_nu "$tmp/ws/demo/trunk" "wt migrate | ignore"
96 +expect_fail "$tmp/ws" "wt ls | ignore"
97 +expect_fail "$tmp/ws/demo/trunk" "co . | ignore"
98 +expect_fail "$tmp/ws/demo/trunk" "wt new trunk | ignore"
100 +run_nu "$tmp/ws/demo/trunk" "wt new switch/me --switch | ignore; if \$env.PWD != '$tmp/ws/demo/wt/switch-me' { error make {msg: 'wt new --switch did not cd'} }"
101 +assert_dir "$tmp/ws/demo/wt/switch-me"
102 +run_nu "$tmp/ws/demo/wt/switch-me" "wt remove switch/me --force | ignore"
103 +assert_no_path "$tmp/ws/demo/wt/switch-me"
105 +run_nu "$tmp/ws/demo/trunk" "wt go go/create --create | ignore"
106 +assert_dir "$tmp/ws/demo/wt/go-create"
107 +run_nu "$tmp/ws/demo/wt/go-create" "wt remove go/create --force | ignore"
108 +assert_no_path "$tmp/ws/demo/wt/go-create"
110 +run_nu "$tmp/ws/demo/trunk" "wt new feature/x | ignore"
111 +assert_dir "$tmp/ws/demo/wt/feature-x"
112 +git -C "$tmp/ws/demo/wt/feature-x" status --short --branch >/dev/null
114 +run_nu "$tmp/ws/demo/trunk" "wt lock feature/x"
115 +run_nu "$tmp/ws/demo/trunk" "wt unlock feature/x"
116 +run_nu "$tmp/ws/demo/trunk" "wt lock feature/x testing"
117 +run_nu "$tmp/ws/demo/trunk" "wt unlock feature/x"
118 +run_nu "$tmp/ws/demo/trunk" "wt go feature/x | ignore"
119 +run_nu "$tmp/ws/demo/wt/feature-x" "wt rm feature/x --force | ignore"
120 +assert_no_path "$tmp/ws/demo/wt/feature-x"
122 +run_nu "$tmp/ws/demo/trunk" "wt new clean/remove | ignore"
123 +assert_dir "$tmp/ws/demo/wt/clean-remove"
124 +run_nu "$tmp/ws/demo/trunk" "wt remove clean/remove --branch | ignore"
125 +assert_no_path "$tmp/ws/demo/wt/clean-remove"
126 +! git --git-dir="$tmp/ws/demo/.bare" show-ref --verify --quiet refs/heads/clean/remove || fail "wt remove --branch kept branch"
128 +run_nu "$tmp/ws/demo/trunk" "wt add move/me | ignore"
129 +assert_dir "$tmp/ws/demo/wt/move-me"
130 +run_nu "$tmp/ws/demo/trunk" "wt move move/me '$tmp/ws/demo/wt/moved-me' | ignore"
131 +assert_no_path "$tmp/ws/demo/wt/move-me"
132 +assert_dir "$tmp/ws/demo/wt/moved-me"
133 +git -C "$tmp/ws/demo/wt/moved-me" status --short --branch >/dev/null
134 +run_nu "$tmp/ws/demo/trunk" "wt done move/me --force | ignore"
135 +assert_no_path "$tmp/ws/demo/wt/moved-me"
136 +! git --git-dir="$tmp/ws/demo/.bare" show-ref --verify --quiet refs/heads/move/me || fail "wt done kept branch"
137 +run_nu "$tmp/ws/demo/trunk" "wt prune"
139 +# normal checkout migration: dirty/staged/untracked/ignored/stash preserved, original kept as backup.
140 +git clone "$tmp/origin.git" "$tmp/normal" >/dev/null 2>&1
141 +git -C "$tmp/normal" checkout -b local >/dev/null 2>&1
142 +git -C "$tmp/normal" config user.email test@example.invalid
143 +git -C "$tmp/normal" config user.name test
144 +echo stash > "$tmp/normal/stash.txt"
145 +git -C "$tmp/normal" add stash.txt
146 +git -C "$tmp/normal" stash push -m stash-test >/dev/null
147 +echo '*.log' > "$tmp/normal/.gitignore"
148 +git -C "$tmp/normal" add .gitignore
149 +echo dirty >> "$tmp/normal/root.txt"
150 +echo staged > "$tmp/normal/staged.txt"
151 +git -C "$tmp/normal" add staged.txt
152 +echo untracked > "$tmp/normal/untracked.txt"
153 +echo ignored > "$tmp/normal/ignored.log"
154 +normal_status="$(git -C "$tmp/normal" status --porcelain=v1)"
155 +run_nu "$tmp/normal" "wt migrate --dry | ignore"
156 +run_nu "$tmp/normal" "wt migrate | ignore"
157 +assert_dir "$tmp/normal/.bare"
158 +assert_dir "$tmp/normal/local"
159 +assert_dir "$tmp/normal/wt"
160 +assert_file "$tmp/normal/local/.git"
161 +assert_file "$tmp/normal/local/ignored.log"
162 +[ "$(git -C "$tmp/normal/local" status --porcelain=v1)" = "$normal_status" ] || fail "normal migrate status mismatch"
163 +git --git-dir="$tmp/normal/.bare" show-ref --verify --quiet refs/stash || fail "normal migrate lost stash"
164 +compgen -G "$tmp/.normal.pre-wt-migrate-*" >/dev/null || fail "normal migrate missing backup"
166 +# detached migration must fail without replacing checkout.
167 +git clone "$tmp/origin.git" "$tmp/detached" >/dev/null 2>&1
168 +git -C "$tmp/detached" checkout --detach >/dev/null 2>&1
169 +expect_fail "$tmp/detached" "wt migrate | ignore"
170 +assert_dir "$tmp/detached/.git"
172 +# legacy bare-container migration: .git admin repo becomes .bare; worktrees move to trunk + wt/<branch>.
173 +mkdir -p "$tmp/legacy"
174 +git clone --bare "$tmp/origin.git" "$tmp/legacy/.git" >/dev/null 2>&1
175 +git --git-dir="$tmp/legacy/.git" config wt.repo-name legacy
176 +git --git-dir="$tmp/legacy/.git" config wt.main-branch trunk
177 +git --git-dir="$tmp/legacy/.git" -c worktree.useRelativePaths=false worktree add "$tmp/legacy/legacy.trunk" trunk >/dev/null
178 +git --git-dir="$tmp/legacy/.git" -c worktree.useRelativePaths=false worktree add -b feature/x "$tmp/legacy/legacy.feature-x" trunk >/dev/null
179 +run_nu "$tmp/legacy/legacy.trunk" "wt migrate | ignore"
180 +assert_dir "$tmp/legacy/.bare"
181 +assert_no_path "$tmp/legacy/.git"
182 +assert_dir "$tmp/legacy/trunk"
183 +assert_dir "$tmp/legacy/wt/feature-x"
184 +git -C "$tmp/legacy/trunk" status --short --branch >/dev/null
185 +git -C "$tmp/legacy/wt/feature-x" status --short --branch >/dev/null
186 +legacy_gitfile="$(cat "$tmp/legacy/trunk/.git")"
187 +[[ "$legacy_gitfile" == "gitdir: $tmp/legacy/.bare/worktrees/"* ]] || fail "legacy gitfile not absolute .bare path: $legacy_gitfile"
188 +[ -z "$(git --git-dir="$tmp/legacy/.bare" config --get extensions.relativeWorktrees || true)" ] || fail "legacy relativeWorktrees set"
189 +[ "$(git --git-dir="$tmp/legacy/.bare" config --bool worktree.useRelativePaths)" = false ] || fail "legacy useRelativePaths not false"
191 +printf 'ok git-worktree-layout\n'