@feigi/fleet-ctl 3.18.0 → 3.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/inflight.sh +62 -62
- package/scripts/no-undo-audit.sh +52 -53
- package/scripts/worktree-audit.sh +43 -44
package/package.json
CHANGED
package/scripts/inflight.sh
CHANGED
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
# found it. Exit 2 from a probe failure carries a payload — the same shape as
|
|
15
15
|
# 0 and 1, plus an "unknown" list naming which probes could not look.
|
|
16
16
|
#
|
|
17
|
-
# Four failures still exit 2 with no payload at all
|
|
18
|
-
# in docs/specs/2026-07-23-fleet-plugin-design.md lists. Three of them land
|
|
17
|
+
# Four failures still exit 2 with no payload at all. Three of them land
|
|
19
18
|
# before anything has been established: a bad argument, not being inside a git
|
|
20
19
|
# repository, and no such issue. That last one fires inside probe 1, after its
|
|
21
20
|
# own `gh issue view` has already run — it is not a pre-probe check, it is the
|
|
@@ -23,14 +22,14 @@
|
|
|
23
22
|
# recording one probe's unknown. The fourth is the opposite end: the verdict
|
|
24
23
|
# itself cannot be written at all, which fails after every probe has finished,
|
|
25
24
|
# with everything established and no way to say it. An evidence string that
|
|
26
|
-
# cannot be rendered is NOT one of the four
|
|
25
|
+
# cannot be rendered is NOT one of the four: the verdict is already
|
|
27
26
|
# correct at that point, and a formatter breaking must not retract it — that
|
|
28
27
|
# field is emitted as JSON null instead, on the payload the verdict already
|
|
29
28
|
# earned. No gap left in that: `jstr`'s own `sed` stage used to be invisible —
|
|
30
29
|
# a pipeline reports only its LAST stage, so a failed `sed` rendered the field
|
|
31
30
|
# as "", the same value "found nothing" uses, with no null and no stderr line.
|
|
32
31
|
# json.sh captures each fallible stage and reads its status, so that failure now
|
|
33
|
-
# reaches `add_evidence` and lands in the null branch like any other
|
|
32
|
+
# reaches `add_evidence` and lands in the null branch like any other.
|
|
34
33
|
set -eu
|
|
35
34
|
|
|
36
35
|
# Byte semantics for the `tr`, `sed` and `awk` below. There is no `grep`: this
|
|
@@ -42,7 +41,7 @@ set -eu
|
|
|
42
41
|
# paths. Under a UTF-8 locale BSD `tr` and `sed` exit 1 on a byte that is not
|
|
43
42
|
# valid UTF-8 — `sed` emitting nothing at all, measured.
|
|
44
43
|
#
|
|
45
|
-
# `awk` is NOT immune, and reap.sh's own
|
|
44
|
+
# `awk` is NOT immune, and reap.sh's own fixture measured the earlier
|
|
46
45
|
# claim here false: it is byte-identical only when every rule matches at an
|
|
47
46
|
# ANCHOR before the bad byte, never needing to convert it — a rule that must
|
|
48
47
|
# SCAN PAST the byte to decide dies instead (BWK awk, macOS: rc 2, `towc:
|
|
@@ -55,19 +54,19 @@ set -eu
|
|
|
55
54
|
#
|
|
56
55
|
# Such a byte reaches us from a fetched tree even where the local filesystem
|
|
57
56
|
# refuses to hold the name, and inside `$(...)` a `tr` failure empties the
|
|
58
|
-
# cause out of the diagnostic without a trace.
|
|
59
|
-
# leaving this ambient in no-undo-audit.sh: a truncated list reported as a
|
|
57
|
+
# cause out of the diagnostic without a trace. The cost of
|
|
58
|
+
# leaving this ambient in no-undo-audit.sh was measured: a truncated list reported as a
|
|
60
59
|
# clean, confident answer.
|
|
61
60
|
#
|
|
62
61
|
# Safe as a global: nothing in this script sorts, folds case, or holds a POSIX
|
|
63
62
|
# class. It does use ONE collation range — `*[!0-9]*`, the issue-number guard
|
|
64
63
|
# below — and a range IS locale-sensitive by spec, its members drawn from the
|
|
65
64
|
# collation sequence rather than the codepoint order. Measured inert here
|
|
66
|
-
#
|
|
65
|
+
# — `0-9` matches the ASCII digits and nothing else under `C`,
|
|
67
66
|
# `en_US.UTF-8`, `de_DE.UTF-8` and `tr_TR.UTF-8` alike, with superscript `²`,
|
|
68
67
|
# Arabic-Indic digits and `½` excluded in all four. So collation and
|
|
69
68
|
# case-folding — the two things `LC_ALL=C` otherwise changes — have nothing
|
|
70
|
-
# here to act on. locale-pin
|
|
69
|
+
# here to act on. The locale-pin prose test holds that inventory as a list and
|
|
71
70
|
# fails if the code drifts from this paragraph in either direction.
|
|
72
71
|
#
|
|
73
72
|
# This completes a pin this script already started: the five `LC_ALL=C` prefixes
|
|
@@ -77,7 +76,7 @@ set -eu
|
|
|
77
76
|
export LC_ALL=C
|
|
78
77
|
|
|
79
78
|
# Below the locale pin, not above it with `set -eu`: `unset` touches no
|
|
80
|
-
# byte-sensitive tool, but locale-pin
|
|
79
|
+
# byte-sensitive tool, but the locale-pin prose test treats ANY line here that
|
|
81
80
|
# is not a comment, a blank, or `set -[eux]+` as work the pin must sit above,
|
|
82
81
|
# and refuses on principle rather than on this line's own behaviour. Same
|
|
83
82
|
# placement, same reason, as release-ticket.sh's copy.
|
|
@@ -86,10 +85,10 @@ export LC_ALL=C
|
|
|
86
85
|
# `rev-parse --git-common-dir`, `for-each-ref`, `worktree list` — so an
|
|
87
86
|
# ambient one asks the WRONG repository whether this ticket is taken.
|
|
88
87
|
# Measured, standing in a checkout that holds both the branch and the
|
|
89
|
-
# worktree for
|
|
90
|
-
# `no local branch or worktree for
|
|
88
|
+
# worktree for ticket <N>, with `GIT_DIR` naming a second clone that holds neither:
|
|
89
|
+
# `no local branch or worktree for #<N>`, and with probes 1 and 2 silent the
|
|
91
90
|
# verdict is `taken: false` on a ticket already claimed. That is the
|
|
92
|
-
# double-claim phase 0 runs this script to prevent, and
|
|
91
|
+
# double-claim phase 0 runs this script to prevent, and the test suite's
|
|
93
92
|
# own fixture builder already deletes both variables for exactly this reason
|
|
94
93
|
# — a defence that protected the SUITE while leaving every real caller
|
|
95
94
|
# exposed.
|
|
@@ -101,16 +100,16 @@ export LC_ALL=C
|
|
|
101
100
|
# there is no behaviour for it to change and no behavioural fixture can pin
|
|
102
101
|
# it. It stays on the line because the pair is one hazard with one remedy,
|
|
103
102
|
# and because "inert today" is a measurement of the current call set, not a
|
|
104
|
-
# property of the script.
|
|
103
|
+
# property of the script. A prose test pins the line
|
|
105
104
|
# itself, which is what keeps that half from being quietly dropped.
|
|
106
105
|
unset GIT_DIR GIT_WORK_TREE
|
|
107
106
|
|
|
108
107
|
NAME=inflight
|
|
109
108
|
die() { printf '%s: %s\n' "$NAME" "$1" >&2; exit 2; }
|
|
110
109
|
|
|
111
|
-
# The escaping helpers
|
|
110
|
+
# The escaping helpers. json.sh's header holds the sourcing contract and
|
|
112
111
|
# the measurements behind it; only what is true of THIS script is repeated here.
|
|
113
|
-
# Below `export LC_ALL=C` deliberately: locale-pin
|
|
112
|
+
# Below `export LC_ALL=C` deliberately: the locale-pin prose test allows only
|
|
114
113
|
# comments, blanks, a shebang or a `set -` line above that pin, and `json_lib=`
|
|
115
114
|
# is none of them.
|
|
116
115
|
#
|
|
@@ -123,7 +122,7 @@ json_lib="$(dirname "$0")/json.sh"
|
|
|
123
122
|
# shellcheck source=json.sh
|
|
124
123
|
. "$json_lib" || die "$json_lib failed to load"
|
|
125
124
|
|
|
126
|
-
# The bounded, prompt-suppressed git transport
|
|
125
|
+
# The bounded, prompt-suppressed git transport. It landed here
|
|
127
126
|
# for probe 2 alone and now lives in net.sh, where every other unattended `git`
|
|
128
127
|
# network call in the fleet reaches it too; net.sh's header holds the reasoning
|
|
129
128
|
# and the measurements. Sourced BELOW json.sh, deliberately: exit 1 from this
|
|
@@ -197,8 +196,8 @@ trap 'rm -f ${errfile:+"$errfile"} ${wtfile:+"$wtfile"} ${wdfile:+"$wdfile"} ||
|
|
|
197
196
|
# merely contained the digits somewhere. Trusting it makes nearly every ticket
|
|
198
197
|
# read as taken, so the fleet skips free work silently and permanently.
|
|
199
198
|
#
|
|
200
|
-
# Nor a closing-keyword regex over the body. Also measured here: PR
|
|
201
|
-
# docs fix ABOUT issue references
|
|
199
|
+
# Nor a closing-keyword regex over the body. Also measured here: a PR that is a
|
|
200
|
+
# docs fix ABOUT issue references quotes `Closes #N.` inside a
|
|
202
201
|
# markdown table. A regex cannot tell quoted text from a real link.
|
|
203
202
|
#
|
|
204
203
|
# Ask GitHub instead. `closedByPullRequestsReferences` is its own resolution of
|
|
@@ -220,7 +219,7 @@ echo "\$ gh issue view $n --json closedByPullRequestsReferences,url" >&2
|
|
|
220
219
|
# a fixed /tmp/.inflight.$$ — guessable from the PID, and `>` follows a
|
|
221
220
|
# symlink, so anything on the host that pre-plants that path pointing at a
|
|
222
221
|
# file this user can write gets it truncated the instant stderr lands there
|
|
223
|
-
# (
|
|
222
|
+
# (measured: a 37-byte victim file left at 14 bytes). mktemp's
|
|
224
223
|
# unpredictable name closes the guess; the trap closes the other half — no
|
|
225
224
|
# cleanup ran for an interrupt landing between the redirect and the `rm -f`
|
|
226
225
|
# that only ever followed a call that finished.
|
|
@@ -350,11 +349,11 @@ print(", ".join(out))') || { add_unknown "pr" "could not filter PR search result
|
|
|
350
349
|
# Measured: the tally then prints the hole, `( full-text match(es) considered)`.
|
|
351
350
|
#
|
|
352
351
|
# `raw="?"` and NOT `add_unknown "pr"; return 1`, which is what stood here and
|
|
353
|
-
# was wrong
|
|
352
|
+
# was wrong. This count feeds nothing but the two diagnostics below: the
|
|
354
353
|
# PR answer is `$pr`, which the guarded filter above already established, so a
|
|
355
354
|
# tally that could not run leaves that answer entirely intact. Returning here
|
|
356
355
|
# discarded an already-sufficient hit over a cosmetic number — measured exit 2
|
|
357
|
-
# with `hits:[]` while `evidence.pr` read
|
|
356
|
+
# with `hits:[]` while `evidence.pr` read `#<pr> OPEN (linked)`. A stage that
|
|
358
357
|
# cannot change the answer must not be able to retract it.
|
|
359
358
|
raw=$(printf '%s' "$pr_json" | python3 -c 'import json,sys;print(len(json.load(sys.stdin)))') \
|
|
360
359
|
|| raw="?"
|
|
@@ -412,26 +411,26 @@ echo "\$ git ls-remote --heads origin" >&2
|
|
|
412
411
|
# can match. git's own wording is more use on the terminal anyway.
|
|
413
412
|
#
|
|
414
413
|
# This is the one network call in the script (probe 1 goes through `gh`, probe
|
|
415
|
-
# 3 never leaves disk), and unattended it must neither prompt nor hang
|
|
414
|
+
# 3 never leaves disk), and unattended it must neither prompt nor hang.
|
|
416
415
|
#
|
|
417
416
|
# The knobs that suppress the prompt and the watchdog that bounds the call both
|
|
418
|
-
# live in net.sh now, which every unattended `git` network call in the
|
|
419
|
-
# routes through
|
|
417
|
+
# live in net.sh now, which every unattended `git` network call in the
|
|
418
|
+
# fleet routes through; its header holds the reasoning and the measurements.
|
|
420
419
|
# What stays here is what is true of THIS call: its budget, and how a killed
|
|
421
420
|
# call is reported.
|
|
422
421
|
#
|
|
423
422
|
# The budget. Above what the ssh options can spend before they give up on their
|
|
424
423
|
# own — ConnectTimeout plus the ServerAlive pair's whole run — so this never
|
|
425
424
|
# preempts a bound that would have produced git's own diagnostic, and short
|
|
426
|
-
# enough that a stalled probe does not hold a fleet slot
|
|
425
|
+
# enough that a stalled probe does not hold a fleet slot.
|
|
427
426
|
# `ls-remote` moves refs and no objects, so this is generous for the work.
|
|
428
427
|
#
|
|
429
428
|
# `INFLIGHT_LS_REMOTE_TIMEOUT` is this call's own override. It can only ever
|
|
430
429
|
# SHORTEN, and the rule with its edge cases is net_budget's, in net.sh.
|
|
431
430
|
ls_budget=$(net_budget 30 "${INFLIGHT_LS_REMOTE_TIMEOUT:-}")
|
|
432
431
|
# A file this probe WANTS, not one it needs. Probe 2 is the one probe that
|
|
433
|
-
# answers when mktemp is broken —
|
|
434
|
-
#
|
|
432
|
+
# answers when mktemp is broken — deliberately so, and the test suite
|
|
433
|
+
# pins it — so a failed mktemp costs the sharper wording
|
|
435
434
|
# below, never the verdict. The old exit-status inference is what the wording
|
|
436
435
|
# falls back to there.
|
|
437
436
|
wdfile=$(mktemp) || wdfile=""
|
|
@@ -527,12 +526,12 @@ probe_remote || :
|
|
|
527
526
|
# could not run at all (git missing, a fork failure, an unreadable packed-refs,
|
|
528
527
|
# which exits 128). That is the floor, not the whole answer: git's own
|
|
529
528
|
# degraded reads exit 0 with output silently missing, which no exit-status
|
|
530
|
-
# guard can see. Measured
|
|
529
|
+
# guard can see. Measured: `chmod 000` on refs/heads or on the worktree
|
|
531
530
|
# admin dir, and both lookups below report nothing, at rc 0, for a ticket that
|
|
532
|
-
# has a live branch or worktree — the same wrong "free"
|
|
531
|
+
# has a live branch or worktree — the same wrong "free" this script exists to rule out,
|
|
533
532
|
# one probe down. Establish each storage was readable before trusting an empty
|
|
534
533
|
# result from it — the same rule release-ticket.sh's `-r`/`-x` guard on
|
|
535
|
-
# `$wtroot` already applies to its own worktree-registry read
|
|
534
|
+
# `$wtroot` already applies to its own worktree-registry read — absence
|
|
536
535
|
# must be established, never inferred.
|
|
537
536
|
#
|
|
538
537
|
# Ceiling, left open on purpose: a single loose ref git skips as corrupt
|
|
@@ -541,7 +540,7 @@ probe_remote || :
|
|
|
541
540
|
# it is not — so it stays undetected. Only counting refs against a source
|
|
542
541
|
# independent of git's own read would catch that, roughly doubling this
|
|
543
542
|
# probe's cost, for a fault that usually breaks much else first; out of scope
|
|
544
|
-
#
|
|
543
|
+
# here.
|
|
545
544
|
probe_local() {
|
|
546
545
|
common=$(git rev-parse --path-format=absolute --git-common-dir) ||
|
|
547
546
|
{ add_unknown "local" "cannot resolve the git common directory"; return 1; }
|
|
@@ -584,15 +583,16 @@ if [ -e "$refsdir" ]; then
|
|
|
584
583
|
# after `cmd | head -1` reports only `head`'s, and `head` exits 0 whether
|
|
585
584
|
# find printed a permission-denied hit or never ran at all (missing binary,
|
|
586
585
|
# a failed exec, any other swallowed crash) — both leave `$bad` empty, both
|
|
587
|
-
# used to read as a clean tree (
|
|
586
|
+
# used to read as a clean tree (reproduced by shimming `find` on
|
|
588
587
|
# PATH to `exit 127`). find's own status is read off the bare command
|
|
589
588
|
# substitution instead, with nothing piped after it, so nothing that runs
|
|
590
589
|
# after it can stand in for it again.
|
|
591
590
|
#
|
|
592
591
|
# `head`'s own status is kept too, not discarded — a `head` that cannot run
|
|
593
592
|
# (crashed, missing) is the same class of failure, and was the one failure
|
|
594
|
-
# this guard could already see before
|
|
595
|
-
# refs-subdirectory walk whose `head` cannot run is unknown,
|
|
593
|
+
# this guard could already see before find's own status was read (pinned
|
|
594
|
+
# below at "a refs-subdirectory walk whose `head` cannot run is unknown,
|
|
595
|
+
# never free").
|
|
596
596
|
# Reading both separately,
|
|
597
597
|
# rather than trusting whichever one the pipeline's single status happens to
|
|
598
598
|
# expose, is what closes the first gap without reopening the second.
|
|
@@ -615,7 +615,7 @@ fi
|
|
|
615
615
|
# found" — so the `local branches:` line and the localBranch evidence below
|
|
616
616
|
# both hand an operator a name they cannot paste into a git command.
|
|
617
617
|
# %(refname) is always refs/heads/<name>, so the strip yields the bare name for
|
|
618
|
-
# every branch, ambiguous or not.
|
|
618
|
+
# every branch, ambiguous or not. reap.sh enumerates the same way.
|
|
619
619
|
#
|
|
620
620
|
# Here the enumeration fix stands ALONE, and that is a finding about THIS
|
|
621
621
|
# script, not a conclusion carried over from that one. What made the fix unsafe
|
|
@@ -623,7 +623,7 @@ fi
|
|
|
623
623
|
# REV (`git cherry "$base" "$b"`), and git resolves an ambiguous rev by
|
|
624
624
|
# preferring refs/tags/ over refs/heads/ — so restoring the bare name made the
|
|
625
625
|
# merge probe answer about the TAG and authorized -D on an unmerged branch
|
|
626
|
-
# (measured
|
|
626
|
+
# (measured; reap.sh qualifies that one site `refs/heads/$b` for exactly
|
|
627
627
|
# this reason). Every site consuming this value here was enumerated and
|
|
628
628
|
# classified instead:
|
|
629
629
|
#
|
|
@@ -639,7 +639,7 @@ fi
|
|
|
639
639
|
# there a `refs/heads/$b` key to rebuild the way reap.sh's worktree lookup has:
|
|
640
640
|
# probe 3's worktree half matches the LISTING's own paths by basename, never a
|
|
641
641
|
# name from this enumeration. `$local_b` is a comma-joined list besides, so it
|
|
642
|
-
# could not be a rev even by accident. Nothing to qualify.
|
|
642
|
+
# could not be a rev even by accident. Nothing to qualify.
|
|
643
643
|
if ! refs=$(git for-each-ref --format='%(refname)' refs/heads); then
|
|
644
644
|
add_unknown "local" "git for-each-ref failed, so whether #$n has a local branch is unknown"
|
|
645
645
|
return 1
|
|
@@ -656,7 +656,7 @@ local_b=$(printf '%s\n' "$refs" | LC_ALL=C awk -v n="$n" '
|
|
|
656
656
|
{ add_unknown "local" "could not filter the local branches for #$n"; return 1; }
|
|
657
657
|
|
|
658
658
|
# Commit the branch half here, where it is established — NOT at the end of the
|
|
659
|
-
# probe with the worktree half
|
|
659
|
+
# probe with the worktree half. Every stage between here and there can
|
|
660
660
|
# fail and `return 1`: the registry read and count, `git worktree list`, the
|
|
661
661
|
# listed-versus-registered compare, the worktree filter. Recording the hit down
|
|
662
662
|
# there meant any one of them threw away a branch that already proves the
|
|
@@ -672,27 +672,27 @@ if [ -n "$local_b" ]; then
|
|
|
672
672
|
fi
|
|
673
673
|
|
|
674
674
|
# The worktree registry's check is a different shape from the one above, on
|
|
675
|
-
# purpose. It began as release-ticket.sh's own fix for this defect
|
|
675
|
+
# purpose. It began as release-ticket.sh's own fix for this defect rather
|
|
676
676
|
# than a second invented convention — but the two copies diverged from there
|
|
677
677
|
# and have converged on most of that ground, but not all of it — see the
|
|
678
678
|
# recount below for what still differs. Three of the four items that
|
|
679
679
|
# landed here first — the stray-directory skip, the awk counter and the
|
|
680
|
-
# direction split — were ported to that copy
|
|
681
|
-
# of the four
|
|
682
|
-
# not its exit STATUS, was a further divergence
|
|
680
|
+
# direction split — were ported to that copy; the recount was the last
|
|
681
|
+
# of the four to follow. That copy's skip reading only `ls`'s output,
|
|
682
|
+
# not its exit STATUS, was a further divergence, since closed: both
|
|
683
683
|
# copies' skip now reads the exit status.
|
|
684
684
|
#
|
|
685
685
|
# Porting the recount did not converge the two copies on it at once, though:
|
|
686
686
|
# this script's recount re-took `registered` alone (`count_registry`), while
|
|
687
687
|
# release-ticket.sh's copy of the SAME recount re-took `registered` AND
|
|
688
|
-
# `linked` together
|
|
688
|
+
# `linked` together, because re-taking `registered` by itself
|
|
689
689
|
# leaves `linked` pinned to the first listing and can misname a benign
|
|
690
|
-
# concurrent-worktree race as a fault.
|
|
690
|
+
# concurrent-worktree race as a fault. That divergence is closed here: both
|
|
691
691
|
# copies now re-take the pair, this one through the `count_linked` below. The
|
|
692
692
|
# mechanism under it is still each script's own — that copy reads the listing
|
|
693
693
|
# through worktree.sh's `wt_listing`, this one through the single EXIT trap's
|
|
694
694
|
# `$wtfile` — a difference in plumbing, same as before. What is no longer true
|
|
695
|
-
# is that the recount ITSELF is:
|
|
695
|
+
# is that the recount ITSELF is: release-ticket.sh's copy is bounded at up
|
|
696
696
|
# to two recount passes (`recount_tries`) to close a residual third-mutation
|
|
697
697
|
# race window that this script's own still-single-pass recount does not
|
|
698
698
|
# close.
|
|
@@ -700,8 +700,8 @@ fi
|
|
|
700
700
|
# A directory-level read+execute test alone is not enough
|
|
701
701
|
# here: naming a registry entry needs read+execute on the PARENT only, so a
|
|
702
702
|
# `gitdir` file chmod'd 000 INSIDE one entry passes every test on the entry
|
|
703
|
-
# itself while `worktree list --porcelain` still drops it, at rc 0
|
|
704
|
-
#
|
|
703
|
+
# itself while `worktree list --porcelain` still drops it, at rc 0
|
|
704
|
+
# (measured). Count registry entries on disk against what git reported instead —
|
|
705
705
|
# that catches a silent drop whichever file inside the entry was unreadable.
|
|
706
706
|
wtroot="$common/worktrees"
|
|
707
707
|
# A function because the count is taken twice — see the recount below. Absent
|
|
@@ -736,7 +736,7 @@ count_registry() {
|
|
|
736
736
|
# and an output-only skip counts 0 to match), no mismatch fires, and the
|
|
737
737
|
# probe answers `taken=false` for a ticket whose checkout is still on disk.
|
|
738
738
|
# Could not read it, so we cannot tell → count it and let the mismatch
|
|
739
|
-
# below fire.
|
|
739
|
+
# below fire.
|
|
740
740
|
if contents=$(ls -A "$entry" 2>/dev/null) && [ -z "$contents" ]; then continue; fi
|
|
741
741
|
registered=$((registered + 1))
|
|
742
742
|
done
|
|
@@ -752,10 +752,10 @@ count_registry || return 1
|
|
|
752
752
|
# `--porcelain -z`, into a temp file rather than a command substitution. The
|
|
753
753
|
# plain porcelain terminates every attribute with a newline, and a worktree
|
|
754
754
|
# path may legally contain one (APFS and ext4 both allow it), so one record
|
|
755
|
-
# splits into two. Measured on the plain form
|
|
755
|
+
# splits into two. Measured on the plain form: `…/wt/fix-66-a<LF>b`
|
|
756
756
|
# reported `worktree` truncated at `…/fix-66-a`, a path not on disk; and
|
|
757
757
|
# `…/wt/plain<LF>fix-33-slug` left the number on the orphaned second line,
|
|
758
|
-
# where the `^worktree ` filter never looked, so
|
|
758
|
+
# where the `^worktree ` filter never looked, so that ticket came back `taken=false` at
|
|
759
759
|
# exit 0 with its checkout live — the one answer this script must never invent.
|
|
760
760
|
# A temp file because `-z`'s separator is NUL and no shell variable can hold
|
|
761
761
|
# one, and because it keeps the lookup's status readable on its own, apart from
|
|
@@ -775,7 +775,7 @@ fi
|
|
|
775
775
|
# the `-ge 1` guard below checks, never read outside this function, matching
|
|
776
776
|
# release-ticket.sh's own `count_linked`, whose comment (line 383) likewise
|
|
777
777
|
# names only `linked` and `wt_list`/`wt_err`. Mirrors that same extraction over
|
|
778
|
-
# the same pair for the same recount
|
|
778
|
+
# the same pair for the same recount.
|
|
779
779
|
#
|
|
780
780
|
# The `mktemp` stays ABOVE this function rather than moving inside it, where
|
|
781
781
|
# release-ticket.sh's `wt_listing` creates and removes one of its own: the temp
|
|
@@ -852,7 +852,7 @@ count_linked() {
|
|
|
852
852
|
# with no linked worktree — a guard that refused that would make every probe in
|
|
853
853
|
# a clean repo unknown. Real `git worktree list --porcelain` always prints the
|
|
854
854
|
# main worktree, so reaching this needs a broken or shimmed git; the refusal
|
|
855
|
-
# direction was already right, only the number was nonsense.
|
|
855
|
+
# direction was already right, only the number was nonsense.
|
|
856
856
|
[ "$listed" -ge 1 ] ||
|
|
857
857
|
{ add_unknown "local" "git listed no worktrees at all for #$n — not even the main checkout, so the listing cannot be trusted"; return 1; }
|
|
858
858
|
linked=$((listed - 1))
|
|
@@ -870,12 +870,12 @@ count_linked || return 1
|
|
|
870
870
|
# FIRST count and git's listing is already reflected in that listing, so the
|
|
871
871
|
# second count agrees with it — the invariant the ORIGINAL pair above relies
|
|
872
872
|
# on. Escaping still needs a SECOND mutation inside the recount's own window.
|
|
873
|
-
# The two rates
|
|
873
|
+
# The two rates measured for recounting at all — 1.99% → 0.00% at
|
|
874
874
|
# λ = 2/s, 56.6% → 1.29% saturated — were taken on the registered-only
|
|
875
875
|
# recount this replaces, so that 1.29% residual bounds what narrowing the
|
|
876
876
|
# window below can still leave rather than describing it; it was not
|
|
877
877
|
# re-measured after that change. A real dropped entry is a standing state,
|
|
878
|
-
# not a moment, so it survives the recount and still refuses (verified:
|
|
878
|
+
# not a moment, so it survives the recount and still refuses (verified: an
|
|
879
879
|
# unreadable `gitdir` still aborts).
|
|
880
880
|
#
|
|
881
881
|
# BOTH counts, not `registered` alone, which is what that invariant costs.
|
|
@@ -895,8 +895,8 @@ count_linked || return 1
|
|
|
895
895
|
# above takes them, hands the RECOUNT pair the invariant too: the window an
|
|
896
896
|
# escape needs is the narrow gap these two calls open between themselves, not
|
|
897
897
|
# the whole span back to the first listing. Both directions pinned in
|
|
898
|
-
#
|
|
899
|
-
#
|
|
898
|
+
# the test suite. Mirrors release-ticket.sh's copy of this recount, which
|
|
899
|
+
# is fixed the same way.
|
|
900
900
|
#
|
|
901
901
|
# The retake pair above is still two reads, not one, and the gap it opens
|
|
902
902
|
# between ITSELF — after `count_registry` has already re-scanned but before
|
|
@@ -907,7 +907,7 @@ count_linked || return 1
|
|
|
907
907
|
# registered`, "the registry read missed entries git can see" — while a
|
|
908
908
|
# REMOVE the same way lands `linked -lt registered`, "the listing is
|
|
909
909
|
# incomplete", indistinguishable from the fault that message exists to name
|
|
910
|
-
# even though nothing here is actually wrong. Pinned in
|
|
910
|
+
# even though nothing here is actually wrong. Pinned in the test suite.
|
|
911
911
|
# Reordering to `count_linked && count_registry` does not remove this
|
|
912
912
|
# residual, it only moves the ADD case's false report onto the
|
|
913
913
|
# `linked -lt registered` branch instead — the direction the comment below
|
|
@@ -1026,12 +1026,12 @@ echo "$NAME: #$n taken=$taken" >&2
|
|
|
1026
1026
|
# remote — carries one in; a worktree path is a filename, so it carries in `\`
|
|
1027
1027
|
# as well, which git's ref rules reject. Raw, either emits a payload no JSON
|
|
1028
1028
|
# parser accepts. The rule list and its ordering live in json.sh, once, rather
|
|
1029
|
-
# than here and in release-ticket.sh and in no-undo-audit.sh
|
|
1029
|
+
# than here and in release-ticket.sh and in no-undo-audit.sh.
|
|
1030
1030
|
#
|
|
1031
1031
|
# The other three interpolations are not strings and are not wrapped: `$n` is
|
|
1032
1032
|
# refused unless it is all digits AND unpadded (the guard's `0?*` arm), which is
|
|
1033
1033
|
# what makes it a JSON number and not merely numeric — RFC 8259 forbids a
|
|
1034
|
-
# leading zero, so `007` never reaches this printf
|
|
1034
|
+
# leading zero, so `007` never reaches this printf; `$taken` is this
|
|
1035
1035
|
# script's own true/false, `$hits` only the fixed literals `add_hit` is given.
|
|
1036
1036
|
# `$pr` is wrapped with the rest — GitHub's own repo, number and state
|
|
1037
1037
|
# vocabulary cannot currently produce a quote, so it is uniformity against a
|
|
@@ -1043,7 +1043,7 @@ echo "$NAME: #$n taken=$taken" >&2
|
|
|
1043
1043
|
# malformed JSON at exit 0. Assigned first, each one is a simple command whose
|
|
1044
1044
|
# status this function can read.
|
|
1045
1045
|
#
|
|
1046
|
-
# `die` is NOT the answer here
|
|
1046
|
+
# `die` is NOT the answer here, unlike everywhere else in this script.
|
|
1047
1047
|
# The verdict — $taken, $hits, $rc — is already correct by this point; a
|
|
1048
1048
|
# formatter that broke AFTER a real answer was established must not convert
|
|
1049
1049
|
# that answer into "unanswerable". So a field jstr or jrewritten could not
|
|
@@ -1051,7 +1051,7 @@ echo "$NAME: #$n taken=$taken" >&2
|
|
|
1051
1051
|
# looked and found nothing" — and the run continues to the payload it earned,
|
|
1052
1052
|
# at the verdict's own exit code. A failed `sed` inside `jstr` used to escape
|
|
1053
1053
|
# this branch entirely and reach `""` unannounced; json.sh reads each stage's
|
|
1054
|
-
# own status, so it arrives here as a non-zero return like any other
|
|
1054
|
+
# own status, so it arrives here as a non-zero return like any other.
|
|
1055
1055
|
#
|
|
1056
1056
|
# The message names the escaper, not just the field, because the two fail
|
|
1057
1057
|
# independently: jstr can render a string perfectly while jrewritten cannot
|
package/scripts/no-undo-audit.sh
CHANGED
|
@@ -20,14 +20,14 @@ set -eu
|
|
|
20
20
|
# byte landed somewhere sed tolerates. `paste -sd, -` truncates its whole
|
|
21
21
|
# output at the byte while still exiting 0.
|
|
22
22
|
#
|
|
23
|
-
# `awk` is NOT immune, and reap.sh's own
|
|
23
|
+
# `awk` is NOT immune, and reap.sh's own fixture measured the earlier
|
|
24
24
|
# claim here false: it is byte-identical only when every rule matches at an
|
|
25
25
|
# ANCHOR before the bad byte, never needing to convert it — a rule that must
|
|
26
26
|
# SCAN PAST the byte to decide dies instead (BWK awk, macOS: rc 2, `towc:
|
|
27
27
|
# multibyte conversion failure`), and under `set -eu` that death aborts the
|
|
28
28
|
# whole script rather than mis-scoring one record. Reachable only from a
|
|
29
29
|
# fetched tree — a Linux- or latin-1-authored commit — since APFS refuses to
|
|
30
|
-
# hold the name locally.
|
|
30
|
+
# hold the name locally.
|
|
31
31
|
#
|
|
32
32
|
# What that cost was measured on the pipeline that used to split merge-tree's
|
|
33
33
|
# output: PIPESTATUS `1 0 0` — its first stage exiting 1 and truncating, the
|
|
@@ -36,17 +36,17 @@ set -eu
|
|
|
36
36
|
# was watching either, so a conflicting path carrying such a byte dropped every
|
|
37
37
|
# path after it and reported `atRisk: []` at exit 0: a FALSE SAFE from the one
|
|
38
38
|
# tool whose whole job is to say whether a rebase would eat a commit. That
|
|
39
|
-
# split is now a single byte-oriented reader whose status nothing discards
|
|
40
|
-
#
|
|
39
|
+
# split is now a single byte-oriented reader whose status nothing discards,
|
|
40
|
+
# so this pin is no longer the only thing standing between that byte
|
|
41
41
|
# and a false safe there. Nor is it anywhere else: the `sed` and `tr` below
|
|
42
42
|
# that render a path or git's own diagnostic to stderr used to take the audit
|
|
43
43
|
# down with them on that byte, at the exit status that means dirty, and since
|
|
44
|
-
#
|
|
44
|
+
# then each renders through a guard (`render`, and the fold in the stash
|
|
45
45
|
# branch) whose failure cannot reach the verdict. What the pin still buys is
|
|
46
46
|
# those renders WORKING: unpinned, BSD sed exits emitting nothing and BSD tr
|
|
47
47
|
# exits truncating, so the operator loses the diagnostic while the payload and
|
|
48
48
|
# the exit status stay correct. That is now the whole cost of removing it here,
|
|
49
|
-
# and
|
|
49
|
+
# and the test suite's invalid-UTF-8 case is what measures it — grep
|
|
50
50
|
# this file for those renders; json.sh's escapers do not rely on this pin,
|
|
51
51
|
# pinning the locale on each call instead.
|
|
52
52
|
#
|
|
@@ -60,22 +60,22 @@ set -eu
|
|
|
60
60
|
# is always `t`. That one site is why this paragraph says "one, unreachable"
|
|
61
61
|
# where the five sibling scripts' copies say "none" — two of theirs now name a
|
|
62
62
|
# `*[!0-9]*` range instead, this one is the POSIX-class exception.
|
|
63
|
-
# locale-pin
|
|
64
|
-
# code drifts from them
|
|
63
|
+
# The locale-pin prose test holds all six inventories as lists and fails if the
|
|
64
|
+
# code drifts from them; this paragraph is why the entry below exists.
|
|
65
65
|
# Non-ASCII paths are untouched either way:
|
|
66
66
|
# every scrub set below is \001-\037 and every byte of a multi-byte UTF-8
|
|
67
67
|
# sequence is >= \200.
|
|
68
68
|
export LC_ALL=C
|
|
69
69
|
|
|
70
70
|
# Below the locale pin, not above it with `set -eu`: `unset` touches no
|
|
71
|
-
# byte-sensitive tool, but locale-pin
|
|
71
|
+
# byte-sensitive tool, but the locale-pin prose test treats ANY line here that
|
|
72
72
|
# is not a comment, a blank, or `set -[eux]+` as work the pin must sit above,
|
|
73
73
|
# and refuses on principle rather than on this line's own behaviour. Same
|
|
74
74
|
# placement, same reason, as release-ticket.sh's copy.
|
|
75
75
|
#
|
|
76
76
|
# The `--show-prefix` gate below is the guard against exactly this class —
|
|
77
77
|
# "can git operate here" is not "is this the tree it answers about" — and the
|
|
78
|
-
# environment walks straight past it. Both halves measured
|
|
78
|
+
# environment walks straight past it. Both halves measured.
|
|
79
79
|
#
|
|
80
80
|
# GIT_WORK_TREE outranks `-C`, so `git -C "$wt" rev-parse --show-prefix`
|
|
81
81
|
# answers about the AMBIENT tree. When that tree is not an ancestor of the
|
|
@@ -100,16 +100,15 @@ NAME=no-undo-audit
|
|
|
100
100
|
# caller-supplied path, and `emit` below is the one place they all route
|
|
101
101
|
# through. Reached by a CALL, not by a second copy of `emit`'s body spelled
|
|
102
102
|
# here, which is what this line used to be: hand-copied the guard was
|
|
103
|
-
# correct and stayed correct, but
|
|
104
|
-
#
|
|
105
|
-
# way (#1684).
|
|
103
|
+
# correct and stayed correct, but adding the SIGPIPE trap then meant editing
|
|
104
|
+
# both copies, and a call is the only form that cannot be missed that way.
|
|
106
105
|
#
|
|
107
106
|
# What `die` needs from that guard is the header's rule below applied to the
|
|
108
107
|
# one write whose statement MUST still reach an exit: `set -e` reads the
|
|
109
108
|
# write's status before `exit` is ever reached, and with fd 2 closed that
|
|
110
109
|
# status is 1 — REFUSED on this script — so every unanswerable question
|
|
111
|
-
# blamed the worktree instead of saying it could not be answered
|
|
112
|
-
# measured: a path that is not a worktree, `2>&-`, exit 1 where the contract
|
|
110
|
+
# blamed the worktree instead of saying it could not be answered
|
|
111
|
+
# (measured: a path that is not a worktree, `2>&-`, exit 1 where the contract
|
|
113
112
|
# says 2).
|
|
114
113
|
#
|
|
115
114
|
# `emit` is defined below, after `render`, and a shell resolves a function
|
|
@@ -127,11 +126,11 @@ die() { emit "$NAME: $1"; exit 2; }
|
|
|
127
126
|
# failed write, and 1 out of here is the dirty-worktree refusal: with fd 2
|
|
128
127
|
# closed, a clean tree came back "commit the worktree before rebasing", from
|
|
129
128
|
# the one tool whose job is to say whether a rebase would eat a commit.
|
|
130
|
-
# Measured before the fix — clean tree, stdout open, `2>&-`: exit 1
|
|
129
|
+
# Measured before the fix — clean tree, stdout open, `2>&-`: exit 1.
|
|
131
130
|
#
|
|
132
131
|
# The guard is centralized, never hand-appended per site: `render` carries
|
|
133
132
|
# it in a function body every caller inherits, and every other write to fd 2
|
|
134
|
-
# — `die`'s own included
|
|
133
|
+
# — `die`'s own included — goes through `emit()` (defined after
|
|
135
134
|
# `render`), which does the same. A future call site cannot add an unguarded
|
|
136
135
|
# `>&2` write without also adding a new function to sidestep it, and there
|
|
137
136
|
# are two guard bodies to keep in step rather than three. `|| :` is the third
|
|
@@ -151,7 +150,7 @@ die() { emit "$NAME: $1"; exit 2; }
|
|
|
151
150
|
# receives it — on the spot, mid-syscall, before the interpreter ever returns
|
|
152
151
|
# to evaluate the `||` that follows. `|| :` cannot catch a kill; it can only
|
|
153
152
|
# catch a status, and a killed process never produces one for this shell to
|
|
154
|
-
# read (
|
|
153
|
+
# read (measured: a reader that exits before the script finishes
|
|
155
154
|
# writing — not merely a closed fd — took the whole process out at 141,
|
|
156
155
|
# outside the script's own 0/1/2 contract).
|
|
157
156
|
#
|
|
@@ -177,7 +176,7 @@ die() { emit "$NAME: $1"; exit 2; }
|
|
|
177
176
|
# Every operator-facing render that pipes a captured value through an external
|
|
178
177
|
# tool goes through here — bar the stash-diagnostic fold below, which folds
|
|
179
178
|
# rather than indents and carries the same guard inline — and the point of it
|
|
180
|
-
# is that a render CANNOT decide the verdict
|
|
179
|
+
# is that a render CANNOT decide the verdict.
|
|
181
180
|
# Written bare — `printf '%s\n' "$v" | sed 's/^/ /' >&2` — the pipeline's
|
|
182
181
|
# status is sed's, `set -eu` takes it, and the script exits with it: on this
|
|
183
182
|
# script exit 1 is the dirty-worktree refusal, so a render fabricated that
|
|
@@ -200,8 +199,8 @@ die() { emit "$NAME: $1"; exit 2; }
|
|
|
200
199
|
# one more command whose status `set -e` reads, and it would abort for the
|
|
201
200
|
# reason this function exists to remove. The second and third pieces used to
|
|
202
201
|
# be spelled out here, a hand copy of `emit`'s own body; now they are a CALL
|
|
203
|
-
# to it
|
|
204
|
-
#
|
|
202
|
+
# to it, for the same reason `die` stopped carrying its own copy
|
|
203
|
+
# — a hand-copied guard is correct only until the next edit to the
|
|
205
204
|
# original forgets to touch both.
|
|
206
205
|
#
|
|
207
206
|
# `$1` lands in sed's REPLACEMENT text, where `&` and `\` are metacharacters.
|
|
@@ -221,9 +220,9 @@ render() { # render <line-prefix> <text> <what-the-text-is>
|
|
|
221
220
|
emit() { ( trap '' PIPE; printf '%s\n' "$1" >&2 ) || :; }
|
|
222
221
|
|
|
223
222
|
|
|
224
|
-
# The escaping helpers
|
|
223
|
+
# The escaping helpers. json.sh's header holds the sourcing contract and
|
|
225
224
|
# the measurements behind it; only what is true of THIS script is repeated here.
|
|
226
|
-
# Below `export LC_ALL=C` deliberately: locale-pin
|
|
225
|
+
# Below `export LC_ALL=C` deliberately: the locale-pin prose test allows only
|
|
227
226
|
# comments, blanks, a shebang or a `set -` line above that pin, and `json_lib=`
|
|
228
227
|
# is none of them.
|
|
229
228
|
#
|
|
@@ -242,7 +241,7 @@ json_lib="$(dirname "$0")/json.sh"
|
|
|
242
241
|
# or a control byte that git's ref rules would reject. The rule list, its
|
|
243
242
|
# ordering and the jarr/jstr split live in json.sh, once, rather than here and
|
|
244
243
|
# in inflight.sh and in release-ticket.sh — five copies of the same rules
|
|
245
|
-
# before the extraction, counting jarr and jarr_rewritten
|
|
244
|
+
# before the extraction, counting jarr and jarr_rewritten.
|
|
246
245
|
#
|
|
247
246
|
# This script is the only caller that reaches the multi-line machinery: `$wt`
|
|
248
247
|
# is the one value here that can carry a newline, which is why json.sh's slurp
|
|
@@ -254,7 +253,7 @@ base=${BASE_REF:-origin/main}
|
|
|
254
253
|
# Only a remote-tracking ref is accepted — the accept-list `case` that
|
|
255
254
|
# release-ticket.sh and reap.sh carry, and the one this script had none of.
|
|
256
255
|
# worktree-audit.sh carries the same accept-list `case` and already applies the
|
|
257
|
-
#
|
|
256
|
+
# shorthand fix: its `base_rev` qualify `case` turns `$base` into
|
|
258
257
|
# `$base_rev`, and both its `rev-parse --verify "$base_rev"` and its
|
|
259
258
|
# `rev-list --count "$base_rev"..HEAD` read `$base_rev`, never the bare
|
|
260
259
|
# shorthand. Its stake is smaller, though: being audit-only,
|
|
@@ -388,7 +387,7 @@ branch_rev="refs/remotes/origin/$branch"
|
|
|
388
387
|
# false-refusal classes `--show-prefix` cannot have, comparing nothing. It is
|
|
389
388
|
# asked further down all the same, against a CANONICAL `$wt`, for the one claim
|
|
390
389
|
# `--show-prefix` cannot make: which working tree git answers for once
|
|
391
|
-
# `core.worktree` has moved it
|
|
390
|
+
# `core.worktree` has moved it. git's
|
|
392
391
|
# `prunable` is no use either: it marks a worktree whose DIRECTORY is gone, and
|
|
393
392
|
# stays silent for one still holding work whose linkage broke (measured).
|
|
394
393
|
prefix=$(git -C "$wt" rev-parse --show-prefix) \
|
|
@@ -402,14 +401,14 @@ prefix=$(git -C "$wt" rev-parse --show-prefix) \
|
|
|
402
401
|
# actually $wt's". A `.git` file rewritten to name a SIBLING worktree's admin
|
|
403
402
|
# dir still resolves its root to $wt (the file's location did not move) while
|
|
404
403
|
# every git command below — `status` included — answers against the sibling's
|
|
405
|
-
# HEAD and index.
|
|
404
|
+
# HEAD and index.
|
|
406
405
|
#
|
|
407
406
|
# So the second claim is asked separately: which git dir answered, and which
|
|
408
407
|
# worktree does THAT dir belong to. Never keyed on the string `--git-dir`
|
|
409
408
|
# returns without `--path-format=absolute`: that is the literal `.git` for a
|
|
410
409
|
# main checkout AND — measured, git 2.50.1 — for a LINKED worktree whose `.git`
|
|
411
410
|
# is a SYMLINK to another worktree's admin dir, so a guard exempting `.git` as
|
|
412
|
-
# "the main worktree, nothing to verify" exempts the
|
|
411
|
+
# "the main worktree, nothing to verify" exempts the sibling spoof spelled as a
|
|
413
412
|
# symlink instead of a `gitdir:` file. Absolute, and compared as paths: the one
|
|
414
413
|
# place in the script that compares paths, because unlike `--show-prefix` there
|
|
415
414
|
# is no rc/emptiness shortcut for "do these two name the same tree".
|
|
@@ -426,7 +425,7 @@ prefix=$(git -C "$wt" rev-parse --show-prefix) \
|
|
|
426
425
|
# one shape but on every main checkout. `$wt_real` stays canonical only for
|
|
427
426
|
# resolving `$wt` (symlinks, relative paths), not Unicode normalization, so
|
|
428
427
|
# both owner compares below compare as directories (`-ef`) for the same
|
|
429
|
-
# NFC/NFD reason as `$top` below (
|
|
428
|
+
# NFC/NFD reason as `$top` below (detailed there); the `core.worktree`
|
|
430
429
|
# check after them already compares directories, so its own correctness does
|
|
431
430
|
# not depend on `$wt_real`'s spelling either.
|
|
432
431
|
#
|
|
@@ -454,11 +453,11 @@ prefix=$(git -C "$wt" rev-parse --show-prefix) \
|
|
|
454
453
|
# add` can produce.
|
|
455
454
|
#
|
|
456
455
|
# `core.worktree` redirection is NOT caught by either check so far, whatever an
|
|
457
|
-
# earlier version of this comment claimed
|
|
456
|
+
# earlier version of this comment claimed:
|
|
458
457
|
# `--show-prefix` is empty at rc 0 for every redirect shape measured, and this
|
|
459
458
|
# owner check passes the two it can see — `$gd` is $wt's own admin dir with its
|
|
460
459
|
# back-pointer intact when the redirect sits in `config.worktree`, and a foreign
|
|
461
|
-
# git dir not named `.git` is the ceiling's admitted shape. The canonical
|
|
460
|
+
# git dir not named `.git` is the ceiling's admitted shape. The canonical
|
|
462
461
|
# redirect, a foreign git dir literally named `.git`, IS refused here, by the
|
|
463
462
|
# `${gd%/.git}` owner compare, not by `--show-prefix`. The working-tree compare
|
|
464
463
|
# after this block is what refuses the rest.
|
|
@@ -475,7 +474,7 @@ prefix=$(git -C "$wt" rev-parse --show-prefix) \
|
|
|
475
474
|
# `core.worktree` target whose real directory name itself ends in a literal
|
|
476
475
|
# newline byte loses that byte on whichever side of a compare below reads it,
|
|
477
476
|
# so two directories differing only by that byte compare equal — a redirect
|
|
478
|
-
# this script exists to refuse instead reads clean (measured
|
|
477
|
+
# this script exists to refuse instead reads clean (measured). `git
|
|
479
478
|
# worktree add`/`git config core.worktree` both accept the byte as an
|
|
480
479
|
# ordinary path character; nothing upstream rejects it.
|
|
481
480
|
#
|
|
@@ -521,12 +520,12 @@ fi
|
|
|
521
520
|
# not called `.git` whose `core.worktree` is `<dir>`: all pass both checks, and
|
|
522
521
|
# `status` then compares the index against `<dir>`'s files. `<dir>` holding the
|
|
523
522
|
# tracked content — any other checkout of the branch — reads `clean` at rc 0
|
|
524
|
-
# over the work sitting in $wt (measured, git 2.50.1
|
|
523
|
+
# over the work sitting in $wt (measured, git 2.50.1). A `<dir>` INSIDE
|
|
525
524
|
# $wt is the same leak for every file outside it.
|
|
526
525
|
#
|
|
527
526
|
# `--show-toplevel` names the working tree git actually answers for, so it is
|
|
528
527
|
# compared against `$wt_real`, and the union of this with the checks above is
|
|
529
|
-
# the guard: none is dropped, since this one passes the
|
|
528
|
+
# the guard: none is dropped, since this one passes the sibling spoof and
|
|
530
529
|
# a foreign `*/.git` whose `core.worktree` names $wt back. The raw-compare
|
|
531
530
|
# false refusals the `--show-prefix` comment warns about do not arise here:
|
|
532
531
|
# measured passing on a relative, symlinked and `/private`-less `$wt`, after
|
|
@@ -534,12 +533,12 @@ fi
|
|
|
534
533
|
# `--separate-git-dir` clone and a `core.worktree` naming $wt itself.
|
|
535
534
|
#
|
|
536
535
|
# Compared as a DIRECTORY (`-ef`, same device and inode), never as a string,
|
|
537
|
-
# for reap.sh's reason
|
|
536
|
+
# for reap.sh's reason: a worktree whose name is Unicode NFD-composed
|
|
538
537
|
# (`cafe` + U+0301), passed in the PRECOMPOSED spelling `worktree list
|
|
539
538
|
# --porcelain` echoes under the `core.precomposeunicode` git writes into every
|
|
540
539
|
# new repo on macOS, keeps that spelling through `cd && pwd -P`, while
|
|
541
540
|
# `--show-toplevel` answers the on-disk NFD bytes — visually identical,
|
|
542
|
-
# byte-different, one directory (measured, git 2.50.1, Apple Git-155
|
|
541
|
+
# byte-different, one directory (measured, git 2.50.1, Apple Git-155).
|
|
543
542
|
# A byte compare refused every such healthy worktree. `-ef` answers "same
|
|
544
543
|
# directory" for both and for any other spelling the filesystem aliases, and
|
|
545
544
|
# still refuses every redirect — each names a different directory.
|
|
@@ -599,7 +598,7 @@ git -C "$wt" rev-parse --verify "$branch_rev" >/dev/null \
|
|
|
599
598
|
# (`check-ref-format` rejects it, `git branch` refuses to create it), so
|
|
600
599
|
# `$base`, `$branch` and `$fork` cannot carry one.
|
|
601
600
|
#
|
|
602
|
-
# `-uall
|
|
601
|
+
# `-uall` (see reap.sh's branch sweep for the full explanation) — a
|
|
603
602
|
# bare `--porcelain` reads clean over a dirty tree under
|
|
604
603
|
# `status.showUntrackedFiles = no`. Load-bearing here beyond a reap: the merge
|
|
605
604
|
# bot leans on this audit to authorize a REBASE, and the work a rebase
|
|
@@ -660,7 +659,7 @@ fi
|
|
|
660
659
|
# 000` on the same file — same rc pair, same `show-ref` stderr, measured. So
|
|
661
660
|
# the line this branch prints names three causes for four, and `ls -l` on the
|
|
662
661
|
# two files, which is what the runbook sends the operator to read next, shows a
|
|
663
|
-
# healthy mode for that row. Widening either is
|
|
662
|
+
# healthy mode for that row. Widening either is out of scope here.
|
|
664
663
|
#
|
|
665
664
|
# `rev-parse --verify --quiet` cannot do this job: it returns 1 for the
|
|
666
665
|
# unreadable ref FILE for the same reason the list is empty, collapsing that
|
|
@@ -671,7 +670,7 @@ fi
|
|
|
671
670
|
# rc 1 says the REF is absent. It does not say the stash is empty, and the
|
|
672
671
|
# `ref file DELETED` row is the difference: `rm -f .git/refs/stash` leaves the
|
|
673
672
|
# reflog naming commits that are still reachable, and `show-ref` answers 1 for
|
|
674
|
-
# it exactly as it does for a repo that never stashed
|
|
673
|
+
# it exactly as it does for a repo that never stashed. So rc 1 buys a
|
|
675
674
|
# second question rather than a verdict — is the reflog gone too? Only then is
|
|
676
675
|
# `0` a claim this can make. It composes with the discriminant above rather
|
|
677
676
|
# than replacing it: the three states that land on rc 0/128 never reach the
|
|
@@ -700,7 +699,7 @@ fi
|
|
|
700
699
|
# ceiling here and never printed the `0` this once recorded: the path
|
|
701
700
|
# resolution needs search permission on every ancestor, so it fails before the
|
|
702
701
|
# `-s` stat, and it now answers unknown on its own line rather than refusing
|
|
703
|
-
# the whole audit (
|
|
702
|
+
# the whole audit (see the resolution below).
|
|
704
703
|
# `core.logAllRefUpdates=false` is NOT a second one: it suppresses the HEAD
|
|
705
704
|
# reflog, but `git stash push` force-creates `logs/refs/stash` regardless, so
|
|
706
705
|
# such a repo probes normally and reports `unknown` (measured, git 2.50.1).
|
|
@@ -708,7 +707,7 @@ fi
|
|
|
708
707
|
# This does not close every unreadable reflog: one that is merely TRUNCATED —
|
|
709
708
|
# some entries lost, the rest still parses — resolves the ref and returns a
|
|
710
709
|
# nonempty list, so the cross-check sees no disagreement and reports the
|
|
711
|
-
# (too-low) count as exact. That gap is a remaining ceiling.
|
|
710
|
+
# (too-low) count as exact. That gap is a remaining ceiling. A
|
|
712
711
|
# characterization test pins it without closing it — closing it was ruled out
|
|
713
712
|
# separately as not worth the complexity.
|
|
714
713
|
#
|
|
@@ -721,7 +720,7 @@ fi
|
|
|
721
720
|
# signal, which is why the list is captured rather than piped: `| wc -l` made
|
|
722
721
|
# this statement's status `wc`'s, always 0, and git's own rc unrecoverable.
|
|
723
722
|
# Nothing else moves — the count is still the lines the list printed, its stderr
|
|
724
|
-
# is still dropped here, and a list that succeeds is still read as a count.
|
|
723
|
+
# is still dropped here, and a list that succeeds is still read as a count.
|
|
725
724
|
#
|
|
726
725
|
# Only the CORRUPT half of that shape is loud. A non-tip object that is MISSING
|
|
727
726
|
# rather than corrupt leaves the reflog intact too, but `stash list` then skips
|
|
@@ -729,7 +728,7 @@ fi
|
|
|
729
728
|
# (measured: three entries, `rm` the loose object behind `refs/stash@{2}` ->
|
|
730
729
|
# rc 0, two lines, empty stderr, git 2.50.1). Nothing here can tell that from a
|
|
731
730
|
# genuinely shorter stack, so it still reports the exact-looking count and stays
|
|
732
|
-
# under the
|
|
731
|
+
# under the truncated-reflog ceiling above.
|
|
733
732
|
sl_rc=0
|
|
734
733
|
sl=$(git -C "$wt" stash list 2>/dev/null) || sl_rc=$?
|
|
735
734
|
# `awk 'END{print NR}'`, not `wc -l`, and the difference is the empty stack.
|
|
@@ -763,7 +762,7 @@ git -C "$wt" show-ref refs/stash >/dev/null 2>&1 || sr_rc=$?
|
|
|
763
762
|
# path lands on `[ -s "" ]`, false, and prints the confident `0`; the state
|
|
764
763
|
# gets its own emission below instead of falling through to one. git's own
|
|
765
764
|
# `fatal:` naming the path and the errno is left on stderr, unwrapped, as the
|
|
766
|
-
# operator's whole lead on which directory to look at.
|
|
765
|
+
# operator's whole lead on which directory to look at.
|
|
767
766
|
stash_reflog=
|
|
768
767
|
stash_reflog_rc=0
|
|
769
768
|
if [ "$stash" = 0 ] && [ "$sr_rc" = 1 ]; then
|
|
@@ -777,7 +776,7 @@ fi
|
|
|
777
776
|
# ref, and it is the more specific of the two there. What is left for the rc is
|
|
778
777
|
# the state no cross-check can reach: git printed entries and then said it could
|
|
779
778
|
# not finish, so the ref resolves, nothing disagrees, and the number would be
|
|
780
|
-
# short by exactly the entries git refused to read
|
|
779
|
+
# short by exactly the entries git refused to read.
|
|
781
780
|
msg=
|
|
782
781
|
if [ "$stash" = 0 ] && [ "$sr_rc" -ne 1 ]; then
|
|
783
782
|
msg=" stash entries (repo-global, not gated): unknown — the list came back empty but refs/stash is not absent (an unreadable ref or reflog, or a ref pointing at a missing object)"
|
|
@@ -799,7 +798,7 @@ if [ -n "$msg" ]; then
|
|
|
799
798
|
# for BOTH the unreadable and the malformed ref file: one canned line for two
|
|
800
799
|
# causes, naming a null SHA that neither ref holds. It is silent only for the
|
|
801
800
|
# unreadable reflog. Whether that wrong-but-specific line beats this
|
|
802
|
-
# right-but-vague one is
|
|
801
|
+
# right-but-vague one is a separate question; this change captures `stash list` and nothing
|
|
803
802
|
# else.
|
|
804
803
|
#
|
|
805
804
|
# The counting statement above takes git's exit code and nothing else, and
|
|
@@ -809,7 +808,7 @@ if [ -n "$msg" ]; then
|
|
|
809
808
|
# healthy audit to serve the one path that has already decided something is
|
|
810
809
|
# wrong. Here the second call costs nothing: it runs only on a run that is
|
|
811
810
|
# already reporting a fault, which now includes the run whose rc brought it
|
|
812
|
-
# here.
|
|
811
|
+
# here.
|
|
813
812
|
#
|
|
814
813
|
# `2>&1 >/dev/null` in that order captures stderr and drops stdout — the list
|
|
815
814
|
# itself is not wanted, it was already counted. `|| true` is load-bearing
|
|
@@ -930,7 +929,7 @@ git -C "$wt" merge-tree --write-tree --name-only -z "$base_rev" "$branch_rev" >"
|
|
|
930
929
|
# confidence — the false safe the prologue describes, and precisely the outcome
|
|
931
930
|
# the standard below says must be exit 2 instead. `export LC_ALL=C` answers the
|
|
932
931
|
# one byte that was measured getting in; it cannot make a status readable, and
|
|
933
|
-
# any other fault in a prefix stage reproduces the under-report.
|
|
932
|
+
# any other fault in a prefix stage reproduces the under-report.
|
|
934
933
|
#
|
|
935
934
|
# `set -o pipefail` is NOT the alternative, and not merely because POSIX sh
|
|
936
935
|
# lacks it (dash rejects `set -o pipefail` outright). Measured: a healthy
|
|
@@ -940,7 +939,7 @@ git -C "$wt" merge-tree --write-tree --name-only -z "$base_rev" "$branch_rev" >"
|
|
|
940
939
|
# tail unread, and once that tail outgrows a pipe buffer whatever is upstream is
|
|
941
940
|
# still writing when the reader goes away. `pipefail` would turn every such run
|
|
942
941
|
# into a refusal, which is a worse failure than the one it fixes. The control
|
|
943
|
-
# for that is a test rather than this paragraph:
|
|
942
|
+
# for that is a test rather than this paragraph: the test suite builds a
|
|
944
943
|
# run whose unread tail outgrows a pipe buffer and requires a full answer.
|
|
945
944
|
#
|
|
946
945
|
# One reader answers both questions, so there is nothing left to discard a
|
|
@@ -982,7 +981,7 @@ if [ -n "$conflicts" ]; then
|
|
|
982
981
|
else
|
|
983
982
|
emit " no conflicting files"
|
|
984
983
|
fi
|
|
985
|
-
# `jarr`/`jarr_rewritten` return non-zero when a stage fails
|
|
984
|
+
# `jarr`/`jarr_rewritten` return non-zero when a stage fails, and a bare
|
|
986
985
|
# `var=$(pipeline)` under `set -eu` would abort with the failing tool's own
|
|
987
986
|
# status — 1 out of THIS script is the dirty-worktree refusal, fabricated here
|
|
988
987
|
# on a worktree already measured clean, with no payload and nothing on stderr.
|
|
@@ -1019,7 +1018,7 @@ if [ -n "$conflicts" ]; then
|
|
|
1019
1018
|
# nothing sits ahead of it with a status to discard. It used to be
|
|
1020
1019
|
# `printf | sed | tr | xargs`, where the `|| die` could only ever answer for
|
|
1021
1020
|
# the last of the four and a fault in any of the other three under-reported
|
|
1022
|
-
# `at_risk` at exit 0.
|
|
1021
|
+
# `at_risk` at exit 0.
|
|
1023
1022
|
at_risk=$(xargs -0 git -C "$wt" log --oneline "$fork".."$base_rev" -- <"$ps_out") \
|
|
1024
1023
|
|| die "listing commits for the conflicting paths failed (git log or xargs) — cannot tell what a resolution would eat"
|
|
1025
1024
|
# Above ARG_MAX (1048576 on macOS) xargs splits the pathspec list across
|
|
@@ -1080,7 +1079,7 @@ fi
|
|
|
1080
1079
|
# out. Assigned first, each one is a simple command whose status `add_field`
|
|
1081
1080
|
# can read.
|
|
1082
1081
|
#
|
|
1083
|
-
# `die` is NOT the answer here
|
|
1082
|
+
# `die` is NOT the answer here, unlike the conflicts and at-risk escapes
|
|
1084
1083
|
# above, and the difference is which kind of value each renders. Those two are
|
|
1085
1084
|
# FINDINGS — the operator can obtain them nowhere else, and step 5 of the
|
|
1086
1085
|
# no-undo runbook hands `conflicts[]` straight to `git diff -- <path>`, where an
|
|
@@ -1093,7 +1092,7 @@ fi
|
|
|
1093
1092
|
# payload carries is established, and a formatter breaking HERE would convert a
|
|
1094
1093
|
# finished audit into "unanswerable" over the formatting of two values the
|
|
1095
1094
|
# caller typed. Each renders independently and reports JSON `null` when it
|
|
1096
|
-
# cannot, which is what
|
|
1095
|
+
# cannot, which is what inflight.sh does for this same class. Not a
|
|
1097
1096
|
# quieter `""`: a field that could not be escaped has no usable path to hand to
|
|
1098
1097
|
# `git diff` in any case, and `""` is indistinguishable from a path.
|
|
1099
1098
|
#
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
# missing (git would silently answer for the ENCLOSING repo instead, rc 0) are
|
|
17
17
|
# all the unknown state — none of them is ever silently ahead:0, dirty:0, which
|
|
18
18
|
# reads as "nothing here, safe to discard" and is indistinguishable from a
|
|
19
|
-
# genuinely empty worktree.
|
|
19
|
+
# genuinely empty worktree.
|
|
20
20
|
set -eu
|
|
21
21
|
|
|
22
22
|
# Byte semantics for the `awk` and `paste` below — this script runs no `tr`,
|
|
@@ -25,12 +25,12 @@ set -eu
|
|
|
25
25
|
# where the local filesystem refuses to hold the name. `paste -sd, -` is the
|
|
26
26
|
# obvious one — fed `b\377ad.txt` then `plain.txt` it emits the single byte `b`
|
|
27
27
|
# under `en_US.UTF-8` and the whole pair under `C`, exiting 0 both times, a
|
|
28
|
-
# truncation carrying no stderr and no status.
|
|
29
|
-
#
|
|
28
|
+
# truncation carrying no stderr and no status. Leaving this ambient in
|
|
29
|
+
# no-undo-audit.sh was measured to cost the same: a truncated list reported as a
|
|
30
30
|
# clean, confident answer.
|
|
31
31
|
#
|
|
32
32
|
# `awk` used to be the immune one — measured byte-identical under
|
|
33
|
-
# `en_US.UTF-8` and `C` — and
|
|
33
|
+
# `en_US.UTF-8` and `C` — and that has ended: `jesc` below turns git's octal
|
|
34
34
|
# escapes back into bytes with `sprintf("%c", n)`, and that IS locale-sensitive.
|
|
35
35
|
# Measured, `%c` with 195: gawk 5.4.1 emits the two-byte UTF-8 encoding of
|
|
36
36
|
# U+00C3 under `en_US.UTF-8` and the single byte \303 under `C`; BWK awk
|
|
@@ -41,18 +41,18 @@ set -eu
|
|
|
41
41
|
# Safe as a global: nothing in this script sorts, folds case, or uses a `[a-z]`
|
|
42
42
|
# range or a POSIX class, so collation and case-folding — the two things
|
|
43
43
|
# `LC_ALL=C` otherwise changes — have nothing here to act on. "Nothing" is an
|
|
44
|
-
# inventory, not a hope: locale-pin
|
|
44
|
+
# inventory, not a hope: the locale-pin prose test enforces it, because
|
|
45
45
|
# this sentence shipped false in no-undo-audit.sh and a `sort` added below
|
|
46
46
|
# would otherwise leave every test in this suite green.
|
|
47
47
|
export LC_ALL=C
|
|
48
48
|
|
|
49
49
|
# Below the locale pin, not above it with `set -eu`: `unset` touches no
|
|
50
|
-
# byte-sensitive tool, but locale-pin
|
|
50
|
+
# byte-sensitive tool, but the locale-pin prose test treats ANY line here that
|
|
51
51
|
# is not a comment, a blank, or `set -[eux]+` as work the pin must sit above,
|
|
52
52
|
# and refuses on principle rather than on this line's own behaviour. Same
|
|
53
53
|
# placement, same reason, as release-ticket.sh's copy.
|
|
54
54
|
#
|
|
55
|
-
# Both halves are measured on THIS script
|
|
55
|
+
# Both halves are measured on THIS script, and they break it in two
|
|
56
56
|
# different directions — which is why the line names both rather than the one
|
|
57
57
|
# that happened to be found first.
|
|
58
58
|
#
|
|
@@ -71,14 +71,14 @@ export LC_ALL=C
|
|
|
71
71
|
# layout (`.worktrees/` gitignored, so the parent really is clean): a worktree
|
|
72
72
|
# holding an uncommitted file comes back `dirty: 0, dirtyFiles: [],
|
|
73
73
|
# readable: true` — a false CLEAN, at rc 0, indistinguishable from a worktree
|
|
74
|
-
# that genuinely holds nothing. Same shape as
|
|
74
|
+
# that genuinely holds nothing. Same shape as a `showUntrackedFiles=no`
|
|
75
75
|
# silence, reached through the environment instead of the config.
|
|
76
76
|
unset GIT_DIR GIT_WORK_TREE
|
|
77
77
|
|
|
78
78
|
NAME=worktree-audit
|
|
79
79
|
die() { printf '%s: %s\n' "$NAME" "$1" >&2; exit 2; }
|
|
80
80
|
|
|
81
|
-
# No positional argument
|
|
81
|
+
# No positional argument. A caller-supplied path was silently discarded
|
|
82
82
|
# — no `$#` check, no usage — so a missing worktree returned a full audit of
|
|
83
83
|
# every OTHER worktree at exit 0, first row the main checkout. Refuse loudly
|
|
84
84
|
# instead of adding a filter: this script's whole contract is "every worktree,
|
|
@@ -87,7 +87,7 @@ die() { printf '%s: %s\n' "$NAME" "$1" >&2; exit 2; }
|
|
|
87
87
|
# the json_lib guard below, so a refusal never emits a truncated array.
|
|
88
88
|
[ $# -eq 0 ] || die "takes no arguments; audits every worktree"
|
|
89
89
|
|
|
90
|
-
# The escaping helpers
|
|
90
|
+
# The escaping helpers. json.sh's header holds the sourcing contract and
|
|
91
91
|
# the measurements behind it. This script defines no exit 1 at all, so a bare 1
|
|
92
92
|
# out of it is a code its caller has no reading for. Placed here, above the
|
|
93
93
|
# opening `[`, so a missing library refuses before the array is started rather
|
|
@@ -98,7 +98,7 @@ json_lib="$(dirname "$0")/json.sh"
|
|
|
98
98
|
# shellcheck source=json.sh
|
|
99
99
|
. "$json_lib" || die "$json_lib failed to load"
|
|
100
100
|
|
|
101
|
-
# The worktree readers
|
|
101
|
+
# The worktree readers. worktree.sh's header holds the sourcing
|
|
102
102
|
# contract and the measurements behind it, and json.sh's holds the `[ -r ]`
|
|
103
103
|
# reasoning both guards share. Above the opening `[` for the reason the json_lib
|
|
104
104
|
# guard is: a missing library must refuse before the array is started.
|
|
@@ -108,7 +108,7 @@ wt_lib="$(dirname "$0")/worktree.sh"
|
|
|
108
108
|
# shellcheck source=worktree.sh
|
|
109
109
|
. "$wt_lib" || die "$wt_lib failed to load"
|
|
110
110
|
# One unknown state, one place: null counts, readable:false, one reason. Seven
|
|
111
|
-
# call sites below reach this function —
|
|
111
|
+
# call sites below reach this function — the admin-dir-unreadable arm
|
|
112
112
|
# among them — and differ in nothing but that reason, so one more added
|
|
113
113
|
# later cannot half-set the quadruple and emit a record whose counts
|
|
114
114
|
# contradict its own `readable` field. The MISSING branch stays spelled out —
|
|
@@ -120,12 +120,12 @@ unknown() { readable=false; ahead=null; dirty=null; files=""; note=; printf '
|
|
|
120
120
|
# on a claim branch lands HEAD on a commit `origin/main` already has — so a
|
|
121
121
|
# count from HEAD alone read such a worktree as `ahead:0, dirty:0`, the
|
|
122
122
|
# "nothing here" row, while the branch it holds carries unpushed commits.
|
|
123
|
-
# `wt_op_state`
|
|
123
|
+
# `wt_op_state` reads the held branch out of the admin dir; this sets
|
|
124
124
|
# `held` to those refs, relabels `short` with their short names and `note`
|
|
125
125
|
# with the operation, for the count below to run over HEAD and `held`
|
|
126
126
|
# together: that union is the branch's own commits plus whatever a rebase
|
|
127
127
|
# has replayed so far onto HEAD alone. Attached rows are untouched. 1: the
|
|
128
|
-
# admin dir cannot be read, so whether a branch is held is unknown.
|
|
128
|
+
# admin dir cannot be read, so whether a branch is held is unknown.
|
|
129
129
|
#
|
|
130
130
|
# A bisect started from a detached HEAD writes that HEAD's SHA, not a branch,
|
|
131
131
|
# into BISECT_START, and `wt_op_state` still returns it as `refs/heads/<sha>`
|
|
@@ -140,7 +140,7 @@ op_held() {
|
|
|
140
140
|
for h in $wt_op_held; do
|
|
141
141
|
sha=$(git -C "$wt" rev-parse --verify "${h#refs/heads/}^{commit}" 2>/dev/null) || sha=
|
|
142
142
|
# A bisect-from-detached-HEAD write drops here because `$h` never names a
|
|
143
|
-
# real ref (
|
|
143
|
+
# real ref (it is HEAD's own SHA reread as `refs/heads/<sha>`). The
|
|
144
144
|
# sha=name match alone cannot tell that case apart from a real branch that
|
|
145
145
|
# happens to be NAMED as the 40-hex string it also resolves to — so the
|
|
146
146
|
# second, structural check is what actually distinguishes them: a real
|
|
@@ -153,7 +153,7 @@ op_held() {
|
|
|
153
153
|
[ -n "$held" ] || return 0
|
|
154
154
|
short=
|
|
155
155
|
for h in $held; do short="${short:+$short }${h#refs/heads/}"; done
|
|
156
|
-
# `$wt_op` names only the LAST admin marker `wt_op_state` found (
|
|
156
|
+
# `$wt_op` names only the LAST admin marker `wt_op_state` found (its own
|
|
157
157
|
# last-wins scan), so it cannot tell a worktree with ONE operation from one
|
|
158
158
|
# with a rebase stopped and a bisect then started on top of it — both leave
|
|
159
159
|
# BISECT_LOG present and `wt_op=BISECT_LOG`, even though the branch actually
|
|
@@ -176,8 +176,8 @@ op_held() {
|
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
base=${BASE_REF:-origin/main}
|
|
179
|
-
# Only a remote-tracking ref is accepted — the accept-list reap.sh
|
|
180
|
-
#
|
|
179
|
+
# Only a remote-tracking ref is accepted — the accept-list reap.sh and
|
|
180
|
+
# release-ticket.sh both carry, and this script had none of.
|
|
181
181
|
# Unlike those two, this script is audit-only: it prints ahead/dirty counts
|
|
182
182
|
# to stdout and never itself writes to git state, so a fleet controller
|
|
183
183
|
# acting on a wrong number is the whole blast radius, not this process. That
|
|
@@ -194,7 +194,7 @@ case "$base" in
|
|
|
194
194
|
*) die "BASE_REF must be a remote-tracking ref, got '$base'";;
|
|
195
195
|
esac
|
|
196
196
|
|
|
197
|
-
# release-ticket.sh
|
|
197
|
+
# release-ticket.sh found the same bug in the same default: `origin/
|
|
198
198
|
# main` is a SHORTHAND, and git resolves a shorthand through its own
|
|
199
199
|
# disambiguation order (gitrevisions: refs/<name>, refs/tags/<name>,
|
|
200
200
|
# refs/heads/<name>, refs/remotes/<name>, …), in which refs/remotes/origin/
|
|
@@ -203,15 +203,14 @@ esac
|
|
|
203
203
|
# branch, and every measurement against the bare shorthand then answers
|
|
204
204
|
# about the tag's target instead: `ahead` silently reads 0 against a
|
|
205
205
|
# worktree that genuinely carries unpushed work, exactly the "nothing here"
|
|
206
|
-
# signal
|
|
206
|
+
# signal the header says readers take as safe to discard.
|
|
207
207
|
#
|
|
208
208
|
# The fix is to stop MEASURING against the shorthand: qualify it to the full
|
|
209
209
|
# refs/remotes/ path, where there is nothing left to disambiguate, unless it
|
|
210
210
|
# is already qualified. The accept-list above is what makes this qualify
|
|
211
|
-
# step safe rather than a guess —
|
|
212
|
-
#
|
|
213
|
-
#
|
|
214
|
-
# unqualified — it never appears in this script's JSON output, only in
|
|
211
|
+
# step safe rather than a guess — BASE_REF could otherwise name a tag, a SHA
|
|
212
|
+
# or a local branch, leaving no prefix that is always correct. $base itself
|
|
213
|
+
# is left unqualified — it never appears in this script's JSON output, only in
|
|
215
214
|
# `die` text, where the shorthand spelling is what an operator expects to
|
|
216
215
|
# read.
|
|
217
216
|
case "$base" in
|
|
@@ -242,13 +241,13 @@ printf '['
|
|
|
242
241
|
# read past it, AND end the `read -r` line below — two truncations, and the loop
|
|
243
242
|
# saw a shorter path than even the awk had. `wt_listing` swaps both separators
|
|
244
243
|
# before either stage runs, so the path arrives on one line; `nl_path` below is
|
|
245
|
-
# what refuses to stat it.
|
|
244
|
+
# what refuses to stat it.
|
|
246
245
|
#
|
|
247
246
|
# The path goes LAST, and the branch first, because the tab this awk delimits
|
|
248
247
|
# with is itself a byte a path may hold — and `read -r wt br` split such a path
|
|
249
248
|
# at it, reporting a truncated `MISSING on disk` for a worktree that is present
|
|
250
249
|
# and clean, with the tail of its path swallowed into the branch field. That is
|
|
251
|
-
#
|
|
250
|
+
# the newline-path defect's own shape surviving in its own rewrite. With the path last,
|
|
252
251
|
# `read` assigns the whole remainder of the line to the final name whatever it
|
|
253
252
|
# holds, so no byte in a path can split it. The branch cannot take that slot: a
|
|
254
253
|
# ref name rejects a tab outright, which is what makes it safe to read first.
|
|
@@ -262,7 +261,7 @@ while IFS="$(printf '\t')" read -r br wt; do
|
|
|
262
261
|
# substituted byte as a space, so the entry still names which worktree could
|
|
263
262
|
# not be audited, whole, with the byte neutralised. The same ceiling
|
|
264
263
|
# inflight.sh's probe 3 records, and here it costs a diagnosis rather than a
|
|
265
|
-
# verdict.
|
|
264
|
+
# verdict.
|
|
266
265
|
if nl_path "$wt"; then
|
|
267
266
|
unknown "path holds a newline — git's own listing cannot be read back to a name this script can stat"
|
|
268
267
|
elif [ -d "$wt" ]; then
|
|
@@ -280,7 +279,7 @@ while IFS="$(printf '\t')" read -r br wt; do
|
|
|
280
279
|
# `git worktree list --porcelain` emits a `branch refs/heads/...` line for
|
|
281
280
|
# it, so a `[gone]` branch checked out there binds reap.sh's own `$wt` to
|
|
282
281
|
# it — and handles that shape explicitly before its own `-f` linkage guard
|
|
283
|
-
#
|
|
282
|
+
# rather than by construction. Here the guard itself
|
|
284
283
|
# must accept both: a real git dir always has `HEAD` sitting directly in
|
|
285
284
|
# it, and an empty stand-in directory or a dangling symlink — the two
|
|
286
285
|
# shapes a broken/deleted linkage takes, and what leaks the parent's status
|
|
@@ -292,7 +291,7 @@ while IFS="$(printf '\t')" read -r br wt; do
|
|
|
292
291
|
if [ -x "$wt" ] && [ ! -f "$wt/.git" ] && [ ! -f "$wt/.git/HEAD" ]; then
|
|
293
292
|
unknown "no .git linkage — git would answer for the enclosing repo, not this worktree"
|
|
294
293
|
# Below the linkage guard, never above it: `wt_op_state` asks git FROM
|
|
295
|
-
# `$wt`, which without a linkage answers for the enclosing repo.
|
|
294
|
+
# `$wt`, which without a linkage answers for the enclosing repo.
|
|
296
295
|
elif ! op_held; then
|
|
297
296
|
unknown "cannot read its admin dir — a rebase or bisect there may hold a branch HEAD no longer points at"
|
|
298
297
|
# Chain on `&&`, not `|| echo 0`: a piped `wc -l` always exits 0 even when
|
|
@@ -300,23 +299,23 @@ while IFS="$(printf '\t')" read -r br wt; do
|
|
|
300
299
|
# never fires and a permissions/corruption failure reads as "0 ahead, 0
|
|
301
300
|
# dirty" — indistinguishable from a genuinely clean worktree.
|
|
302
301
|
#
|
|
303
|
-
# `-uall
|
|
302
|
+
# `-uall` (see reap.sh's branch sweep for the full explanation) — a
|
|
304
303
|
# bare `--porcelain` reads `dirty: 0` over a dirty tree under
|
|
305
304
|
# `status.showUntrackedFiles = no`, and the `&&` chain above, built
|
|
306
305
|
# precisely so a failure to look is never scored as clean, cannot see it
|
|
307
306
|
# either, because the status IS 0.
|
|
308
307
|
#
|
|
309
308
|
# `-uall` over `-unormal` here specifically, unlike reap.sh's `--ignored`
|
|
310
|
-
# reason-string probe (which
|
|
309
|
+
# reason-string probe (which uses `-unormal`): this
|
|
311
310
|
# report's `dirtyFiles[]` is what a fleet controller reads to decide
|
|
312
|
-
# whether a replacement member would REDO work or DESTROY it, and
|
|
311
|
+
# whether a replacement member would REDO work or DESTROY it, and this script
|
|
313
312
|
# already invested in translating git's C-quoting to JSON precisely so
|
|
314
313
|
# `dirtyFiles[]` round-trips to the real path on disk — infrastructure
|
|
315
314
|
# that exists to let the array name individual files, not just
|
|
316
315
|
# directories. `-unormal` would collapse an untracked directory to one
|
|
317
316
|
# entry, silently dropping that granularity for whoever reads this
|
|
318
317
|
# array. Proven, not just asserted: see the nested-directory test in
|
|
319
|
-
#
|
|
318
|
+
# this script's tests.
|
|
320
319
|
#
|
|
321
320
|
# `$held` unquoted: a space-separated list of full `refs/heads/` names,
|
|
322
321
|
# empty for every attached row, and a ref name holds no space or glob byte.
|
|
@@ -332,9 +331,9 @@ while IFS="$(printf '\t')" read -r br wt; do
|
|
|
332
331
|
# git 2.50.1 — and C-quoting is NOT JSON escaping. `\303\251` for the `é`
|
|
333
332
|
# in `café.txt` is an invalid JSON escape, so ONE such file made the whole
|
|
334
333
|
# array unparseable and cost the caller every other worktree's entry too.
|
|
335
|
-
#
|
|
334
|
+
# The open half of that is settled: TRANSLATE git's form into JSON's, so
|
|
336
335
|
# `dirtyFiles[]` round-trips to the real name on disk. The alternative
|
|
337
|
-
#
|
|
336
|
+
# considered — JSON-escape the C-quoted text itself — parses, but hands
|
|
338
337
|
# a fleet controller a string it cannot pass back to the filesystem, which
|
|
339
338
|
# is the same defect `nl_path` above refuses rather than reports.
|
|
340
339
|
#
|
|
@@ -355,14 +354,14 @@ while IFS="$(printf '\t')" read -r br wt; do
|
|
|
355
354
|
# `jesc` meets \000 as three literal digit characters (git's own octal
|
|
356
355
|
# spelling of the byte), never as an embedded NUL, so the exclusion that
|
|
357
356
|
# protects `tr` does not apply here. Emits the same five short forms, and
|
|
358
|
-
# leaves \177 alone
|
|
357
|
+
# leaves \177 alone.
|
|
359
358
|
if jfiles=$(printf '%s\n' "$status_out" | awk '
|
|
360
359
|
# git C-quoting to JSON, byte for byte. An UNQUOTED path is returned
|
|
361
360
|
# untouched: git quotes for `"`, `\`, any control byte and any byte with
|
|
362
361
|
# the high bit set, so what it left bare is printable ASCII with nothing
|
|
363
362
|
# JSON needs escaped. `index("01234567", c)`, not a `[0-7]` bracket range
|
|
364
|
-
# — locale-pin
|
|
365
|
-
# range here would read as one
|
|
363
|
+
# — the locale-pin prose test scans this file for collation ranges and a
|
|
364
|
+
# range here would read as one. git spells an octal escape with
|
|
366
365
|
# exactly three digits, so the two lookahead reads below always land.
|
|
367
366
|
# jesc_err is a global, deliberately never reset: an unrecognized escape
|
|
368
367
|
# exits the awk program (below) before a second call could matter, so
|
|
@@ -379,7 +378,7 @@ while IFS="$(printf '\t')" read -r br wt; do
|
|
|
379
378
|
out = out (n < 32 ? " " : sprintf("%c", n))
|
|
380
379
|
} else if (c=="a" || c=="v") out=out " "
|
|
381
380
|
else if (index("bfnrt\\\"", c) > 0) out=out "\\" c
|
|
382
|
-
# An escape letter git 2.50.1 never emits (the
|
|
381
|
+
# An escape letter git 2.50.1 never emits (the enumeration
|
|
383
382
|
# above is exhaustive against it) — dead code under real git, same
|
|
384
383
|
# as the header states. Fail loud rather than pass the byte through
|
|
385
384
|
# unescaped: this file has one rule above every other one, never
|
|
@@ -402,7 +401,7 @@ while IFS="$(printf '\t')" read -r br wt; do
|
|
|
402
401
|
# unescaped closing quote, which the scan below finds. Reading the
|
|
403
402
|
# whole rename line as one path put the quotes git had already added
|
|
404
403
|
# inside the pair added below: one such file made the WHOLE payload
|
|
405
|
-
# unparseable, taking every other worktree entry down with it
|
|
404
|
+
# unparseable, taking every other worktree entry down with it.
|
|
406
405
|
if (substr($0,1,1) ~ /[RC]/) {
|
|
407
406
|
if (substr(p,1,1) == "\"") {
|
|
408
407
|
for (i=2; i<=length(p); i++) {
|
|
@@ -420,7 +419,7 @@ while IFS="$(printf '\t')" read -r br wt; do
|
|
|
420
419
|
# Checked here, not after the pipeline: `awk ... | paste -sd, -` would
|
|
421
420
|
# otherwise report the PASTE exit status, and paste never fails on
|
|
422
421
|
# this input — the jesc_err below would kill awk with nothing
|
|
423
|
-
# downstream ever finding out
|
|
422
|
+
# downstream ever finding out.
|
|
424
423
|
if (jesc_err != "") {
|
|
425
424
|
print "jesc: unrecognized C-quote escape \\" jesc_err > "/dev/stderr"
|
|
426
425
|
exit 1
|
|
@@ -444,11 +443,11 @@ while IFS="$(printf '\t')" read -r br wt; do
|
|
|
444
443
|
# so a DANGLING symlink is `-e` false and `-L` true, and without this it fell
|
|
445
444
|
# past both this arm and `gone` into "an ancestor could not be read" — prose
|
|
446
445
|
# that is false of a path whose every ancestor was read fine. `gone` now
|
|
447
|
-
# refuses it too
|
|
446
|
+
# refuses it too, so this arm is where it lands, and the diagnosis
|
|
448
447
|
# below is true of it: a link IS there, and it is not a directory. The
|
|
449
448
|
# wording stays hedged deliberately — a dangling worktree link is rc-0
|
|
450
449
|
# residue OR release-ticket.sh's rc-255 halt path with the claim still live,
|
|
451
|
-
# and only the hedge is true of both
|
|
450
|
+
# and only the hedge is true of both.
|
|
452
451
|
#
|
|
453
452
|
# `-d` false does not mean "not there". A registered worktree path replaced
|
|
454
453
|
# by a regular file, a symlink to one, or a FIFO is all three still LISTED
|
|
@@ -471,7 +470,7 @@ while IFS="$(printf '\t')" read -r br wt; do
|
|
|
471
470
|
# filename and accepts both. This script's whole output is one array, so a
|
|
472
471
|
# single unescaped byte costs the caller every entry, not just this one.
|
|
473
472
|
# `$files` is NOT wrapped here: its elements arrive already quoted and already
|
|
474
|
-
# JSON-escaped, by `jesc` in the `files=` awk above
|
|
473
|
+
# JSON-escaped, by `jesc` in the `files=` awk above.
|
|
475
474
|
# `die` rather than a null field, unlike reap.sh: nothing has been mutated
|
|
476
475
|
# here, so refusing costs no record of work already done.
|
|
477
476
|
wt_j=$(jstr "$wt") && short_j=$(jstr "$short") \
|