git: refresh index stat cache after CLI status

This commit is contained in:
2026-11-07 02:39:08 +00:00
parent 9d11ab381e
commit e1cfaa93bf
4 changed files with 47 additions and 4 deletions
+24
View File
@@ -384,6 +384,30 @@ def main [component: path, server: path = '/tmp/p1-git/server-target/debug/git-t
$executable_ok = ($executable_ok and $indexed.exit_code == 0 and ($indexed.stdout | str starts-with '100755 '))
print $'executable checkout stays clean: (if $executable_ok {"PASS"} else {"FAIL"})'
if not $executable_ok { $failures += 1 }
# Status refreshes stale stats once, then detects a same-size content change.
let cached = ($root | path join cached)
mkdir $cached
^git -C $cached init -q -b main
'base' | save ($cached | path join file.txt)
^git -C $cached add file.txt
^git -C $cached commit --no-gpg-sign -q -m cached
^touch -m -d @1700000000 ($cached | path join file.txt)
let index = ($cached | path join .git/index)
let before = (open --raw $index | hash sha256)
mut cached_ok = true
mut refreshed = ''
for pass in [1 2] {
let result = (^wasmtime run -S http=y -S cli-exit-with-code=y --dir $'($cached)::/cached' $component -C /cached status --short | complete)
let current = (open --raw $index | hash sha256)
$cached_ok = ($cached_ok and $result.exit_code == 0 and $result.stdout == '')
if $pass == 1 { $cached_ok = ($cached_ok and $current != $before); $refreshed = $current } else { $cached_ok = ($cached_ok and $current == $refreshed) }
}
'edit' | save --force ($cached | path join file.txt)
let changed = (^wasmtime run -S http=y -S cli-exit-with-code=y --dir $'($cached)::/cached' $component -C /cached status --short | complete)
let native_changed = (^git -C $cached status --short | complete)
$cached_ok = ($cached_ok and $changed.exit_code == 0 and $changed.stdout == $native_changed.stdout and $changed.stdout == " M file.txt\n")
print $'status caches stats and detects edits: (if $cached_ok {"PASS"} else {"FAIL"})'
if not $cached_ok { $failures += 1 }
# A merge tree that differs from both parents requires a combined diff.
'combined resolution\n' | save --force ($root | path join native/repo/file.txt)
let native = ($root | path join native/repo)