@feigi/fleet-ctl 3.25.0 → 3.27.0
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/commands/review-and-fix.md +1 -0
- package/package.json +1 -1
- package/scripts/dispositions-check.mjs +265 -40
- package/scripts/fleet-tick.mjs +12 -9
- package/scripts/inflight.sh +59 -281
- package/scripts/ledger.mjs +7 -1
- package/scripts/net.sh +2 -2
- package/scripts/no-undo-audit.sh +27 -27
- package/scripts/reap.sh +49 -227
- package/scripts/release-ticket.sh +92 -428
- package/scripts/worktree.sh +498 -1
- package/skills/run-team/SKILL.md +10 -4
- package/skills/run-team/references/reaping.md +1 -1
package/scripts/reap.sh
CHANGED
|
@@ -223,7 +223,7 @@ git rev-parse --git-dir >/dev/null 2>&1 || die "not inside a git repository"
|
|
|
223
223
|
# turned symlink since leaves non-canonical, and which `core.precomposeunicode`
|
|
224
224
|
# prints precomposed for a worktree whose on-disk name is NFD while git's own
|
|
225
225
|
# answer is the NFD bytes (measured, git 2.50.1, Apple Git-155). So
|
|
226
|
-
# `
|
|
226
|
+
# worktree.sh's `wt_holds_cwd` matches on the directory, not only the string.
|
|
227
227
|
#
|
|
228
228
|
# `2>/dev/null` and never `2>&1`, for the reason the in-progress guard below
|
|
229
229
|
# records at its own `rev-parse`: this capture is used as a PATH, not as
|
|
@@ -268,37 +268,6 @@ if [ "$self_wt_rc" -ne 0 ]; then
|
|
|
268
268
|
esac
|
|
269
269
|
fi
|
|
270
270
|
|
|
271
|
-
# True when removing worktree `$1` would delete this run's cwd: `$self_wt` is
|
|
272
|
-
# `$1` or lies anywhere beneath it (a nested worktree). Asked of the
|
|
273
|
-
# DIRECTORY, not the string: `-ef` (same device and inode) of `$self_wt` and of
|
|
274
|
-
# each of its parents in turn. The byte-boundary prefix match this replaces
|
|
275
|
-
# missed the same directory spelled two ways — the symlinked parent and the NFD
|
|
276
|
-
# name the header above records share no prefix with git's own answer — and
|
|
277
|
-
# `--apply` deleted the cwd it was standing in (measured). An empty `$self_wt`
|
|
278
|
-
# (no worktree) names no directory, so it matches
|
|
279
|
-
# nothing; the walk ends when no `/` is left to strip.
|
|
280
|
-
#
|
|
281
|
-
# `elif` on `$?`, same refusing direction `wt_linkage_why` states for its own
|
|
282
|
-
# `-ef`: every shell this file targets (dash, bash, ksh — all three tested)
|
|
283
|
-
# implements it, so a `[` that cannot evaluate it (rc 2) is
|
|
284
|
-
# unreached today, not impossible — and unlike `wt_linkage_why`, nothing
|
|
285
|
-
# downstream of THIS guard re-checks the directory it protects. Reading that
|
|
286
|
-
# rc as a plain "not this one" would silently disable both cwd-delete guards
|
|
287
|
-
# exactly the way an unrecognised `self_wt` failure would (the probe's note
|
|
288
|
-
# above), just one layer further in.
|
|
289
|
-
holds_cwd() {
|
|
290
|
-
hc_d=$self_wt
|
|
291
|
-
while :; do
|
|
292
|
-
# shellcheck disable=SC3013,SC2319 # -ef is a ksh-derived extension bash/dash/BSD sh share, base in POSIX.1-2024; the else's $? is deliberately the `[ -ef ]` test's own rc, read before anything else runs, to fail closed (return 0) on rc>=2 same as wt_linkage_why below
|
|
293
|
-
if [ "$hc_d" -ef "$1" ]; then hc_rc=0; else hc_rc=$?; fi
|
|
294
|
-
if [ "$hc_rc" -eq 0 ] || [ "$hc_rc" -ge 2 ]; then return 0; fi
|
|
295
|
-
case "$hc_d" in
|
|
296
|
-
*/*) hc_d=${hc_d%/*} ;;
|
|
297
|
-
*) return 1 ;;
|
|
298
|
-
esac
|
|
299
|
-
done
|
|
300
|
-
}
|
|
301
|
-
|
|
302
271
|
echo "\$ git fetch --prune origin" >&2
|
|
303
272
|
fetch_budget=$(net_fetch_budget)
|
|
304
273
|
fetch_rc=0
|
|
@@ -539,75 +508,6 @@ gp_why() {
|
|
|
539
508
|
if [ -n "$gp_w" ]; then printf ': %s' "$gp_w"; fi
|
|
540
509
|
}
|
|
541
510
|
|
|
542
|
-
# True when `$1`'s `.git` answers for `$1` itself; otherwise false, with the
|
|
543
|
-
# reason in `$lk_why`. Both sweeps call it once their `-f "$wt/.git"` test has
|
|
544
|
-
# established the linkage EXISTS, and before any git command run through `$wt`
|
|
545
|
-
# is believed — the dirty check first among them.
|
|
546
|
-
#
|
|
547
|
-
# Existing is not answering. Two shapes keep `.git` a well-formed regular file
|
|
548
|
-
# and move git's WORKING TREE elsewhere: a `.git` naming a foreign git dir not
|
|
549
|
-
# called `.git` whose `core.worktree` is another directory, and `core.worktree`
|
|
550
|
-
# set in the worktree's own `config.worktree` under `extensions.worktreeConfig`,
|
|
551
|
-
# `.git` untouched. `git -C "$wt" status` then reads THAT tree, so a clean one
|
|
552
|
-
# there reads clean over the work sitting in `$wt` — the dry run promised a
|
|
553
|
-
# removal `--apply` could not perform, `git worktree remove`'s own back-pointer
|
|
554
|
-
# and untracked-file checks being all that kept the work (measured on both
|
|
555
|
-
# shapes, both sweeps, git 2.50.1). `--show-toplevel` names the tree git
|
|
556
|
-
# actually answers for, so it is compared against `$1`.
|
|
557
|
-
#
|
|
558
|
-
# Compared as a DIRECTORY (`-ef`, same device and inode), never as a string:
|
|
559
|
-
# `$1` is the path `worktree list --porcelain` echoes and `--show-toplevel` is
|
|
560
|
-
# git's own resolved spelling, and the two legitimately differ for one and the
|
|
561
|
-
# same directory. A parent that was a plain directory at `worktree add` time
|
|
562
|
-
# and is a symlink now leaves the listed path non-canonical while git's answer
|
|
563
|
-
# is resolved (measured). And a worktree whose name is Unicode
|
|
564
|
-
# NFD-composed (`cafe` + U+0301) is listed PRECOMPOSED by the
|
|
565
|
-
# `core.precomposeunicode` git writes into every new repo on macOS, while
|
|
566
|
-
# `--show-toplevel` answers the on-disk NFD bytes — visually identical,
|
|
567
|
-
# byte-different, one directory (measured, git 2.50.1, Apple Git-155).
|
|
568
|
-
# `cd && pwd -P` canonicalises only the first: it echoes the spelling it was
|
|
569
|
-
# given, so a byte compare against it kept every healthy NFD worktree forever.
|
|
570
|
-
# `-ef` answers "same directory" for both and for any other spelling the
|
|
571
|
-
# filesystem aliases, and still refuses every redirect — each names a
|
|
572
|
-
# different directory. POSIX.1-2017's own `test` page does not define `-ef`
|
|
573
|
-
# at all, XSI or otherwise — it is a ksh-derived extension bash, dash, and
|
|
574
|
-
# BSD sh already share; POSIX.1-2024 (Austin Group bug 375) is what actually
|
|
575
|
-
# adds it, as a base utility primary. A `[` that cannot evaluate it fails,
|
|
576
|
-
# which is the refusing direction, as is a `--show-toplevel` naming a path
|
|
577
|
-
# that does not exist.
|
|
578
|
-
#
|
|
579
|
-
# `&& echo x` inside the substitution, then `%?x`: `$(...)` strips EVERY
|
|
580
|
-
# trailing newline, so a `core.worktree` naming a sibling directory called
|
|
581
|
-
# `<wt>` plus a newline byte — git accepts one as an ordinary path character —
|
|
582
|
-
# would otherwise name `$1` itself and pass the redirect (measured; the shape
|
|
583
|
-
# no-undo-audit.sh closed the same way). The sentinel leaves `$(...)`
|
|
584
|
-
# only git's own terminating newline to strip.
|
|
585
|
-
#
|
|
586
|
-
# What this does NOT cover, the boundary release-ticket.sh's copy of this
|
|
587
|
-
# compare also states: shapes that swap which git DIR answers while the
|
|
588
|
-
# working tree stays `$1` — a `.git` naming a sibling worktree's admin dir,
|
|
589
|
-
# or a foreign git dir whose `core.worktree` points back at `$1`.
|
|
590
|
-
# `--show-toplevel` answers `$1` for both. The dirty check reads `$1`'s real
|
|
591
|
-
# files against the borrowed index, and `git worktree remove` refuses a
|
|
592
|
-
# `.git` that does not point back at its admin dir, so neither is removed.
|
|
593
|
-
#
|
|
594
|
-
# A git that cannot answer at all is a refusal, never a pass: the reason is
|
|
595
|
-
# fetched with a second call only on that path, the way the cwd guard at the
|
|
596
|
-
# top of this file fetches its own, so the answer the compare reads never
|
|
597
|
-
# carries stderr.
|
|
598
|
-
wt_linkage_why() {
|
|
599
|
-
if ! lk_top=$(git -C "$1" rev-parse --show-toplevel 2>/dev/null && echo x); then
|
|
600
|
-
lk_why="has a .git linkage git cannot resolve$(gp_why "$(git -C "$1" rev-parse --show-toplevel 2>&1 >/dev/null)")"
|
|
601
|
-
return 1
|
|
602
|
-
fi
|
|
603
|
-
lk_top=${lk_top%?x}
|
|
604
|
-
# `if`, never `[ ! … ] || return 0`: a `[` that errors (rc 2) must refuse.
|
|
605
|
-
# shellcheck disable=SC3013 # -ef is a ksh-derived extension bash/dash/BSD sh share, base in POSIX.1-2024; this file targets dash too and -ef is verified there
|
|
606
|
-
if [ "$lk_top" -ef "$1" ]; then return 0; fi
|
|
607
|
-
lk_why="has a .git linkage that answers for $lk_top, not for it — its dirty check would read that tree"
|
|
608
|
-
return 1
|
|
609
|
-
}
|
|
610
|
-
|
|
611
511
|
# Runs `grep -q` over CAPTURED text and hands back grep's own status separately
|
|
612
512
|
# from the verdict grep was asked for.
|
|
613
513
|
#
|
|
@@ -727,20 +627,12 @@ wt_reg_state() {
|
|
|
727
627
|
# backstop exists past this point, so the listing has to be checked against
|
|
728
628
|
# the registry before its silence is read as "no worktree".
|
|
729
629
|
#
|
|
730
|
-
#
|
|
731
|
-
# trusted. Two checks, because the fault families differ in what they leave:
|
|
630
|
+
# Two checks, because the fault families differ in what they leave:
|
|
732
631
|
#
|
|
733
632
|
# (a) COUNT. The `gitdir`/admin-dir/registry-file faults DROP the entry, so
|
|
734
633
|
# fewer linked worktrees are listed than are registered under
|
|
735
|
-
# `<git-common-dir>/worktrees/`. `
|
|
736
|
-
#
|
|
737
|
-
# `count_linked`, the recount at `[ "$linked" -eq "$registered" ] || {
|
|
738
|
-
# count_registry && count_linked; }` and the two direction-named refusals
|
|
739
|
-
# after it) — the stray-`mkdir` skip, the count-what-`ls`-cannot-read rule,
|
|
740
|
-
# the `[ -r ] && [ -x ]` unreadable-registry arm and the `-ge 1` floor all
|
|
741
|
-
# carry that copy's measurements. One tightening: `-d` joins
|
|
742
|
-
# the unreadable arm, because a registry replaced by a mode-755 FILE passes
|
|
743
|
-
# `-r` and `-x`, globs to nothing, counts 0 against git's 0, and agrees.
|
|
634
|
+
# `<git-common-dir>/worktrees/`. worktree.sh's `wt_counts` answers that,
|
|
635
|
+
# with its recount and the measurements behind both.
|
|
744
636
|
#
|
|
745
637
|
# (b) NULL HEAD. The `HEAD` faults keep the entry, so the counts AGREE and
|
|
746
638
|
# (a) sees nothing: git lists it with the null object id and no `branch`
|
|
@@ -752,82 +644,17 @@ wt_reg_state() {
|
|
|
752
644
|
# applies. That arm stays as it is: it reports the worktree, while this one
|
|
753
645
|
# protects the branches. No `/^bare$/` rule here, deliberately: a test
|
|
754
646
|
# fixture selects that sweep's awk by it, and a second carrier would shim
|
|
755
|
-
# this one too.
|
|
647
|
+
# this one too. `null_head_why` below sets `reg_why` and returns 1 on it.
|
|
756
648
|
#
|
|
757
649
|
# Either finding keeps the branch under lookup, whichever it is: a dropped or
|
|
758
650
|
# nameless entry says nothing about WHICH branch it held, so a healthy branch
|
|
759
|
-
# with no worktree is exactly as unclearable as the tampered one.
|
|
760
|
-
#
|
|
761
|
-
#
|
|
762
|
-
#
|
|
763
|
-
#
|
|
764
|
-
#
|
|
765
|
-
|
|
766
|
-
#
|
|
767
|
-
# Recount before refusing, exactly as inflight.sh does it: the
|
|
768
|
-
# registry scan and git's listing are two reads at two instants, and a
|
|
769
|
-
# sibling's `worktree add`/`remove` landing between them makes the counts
|
|
770
|
-
# disagree with nothing wrong. Same order as that copy, first pair and recount
|
|
771
|
-
# alike: `count_registry` FIRST, git's listing SECOND — the loop takes the
|
|
772
|
-
# first registry count just ahead of the `wt_listing` failure guard, whose read
|
|
773
|
-
# is the first listing, so no extra listing is read per branch. A mutation
|
|
774
|
-
# landing between the first count and the listing is already reflected in the
|
|
775
|
-
# listing, so the recount's registry scan agrees with it; the recount re-takes
|
|
776
|
-
# BOTH, in the same order, and re-reads the listing through `wt_listing`, so
|
|
777
|
-
# `$wt_list` — which the lookup then scans — is the very listing the recount
|
|
778
|
-
# validated.
|
|
779
|
-
# inflight.sh's copy recounts once (its `[ "$linked" -eq "$registered" ] ||
|
|
780
|
-
# { count_registry && count_linked; }`); release-ticket.sh's bounds the same
|
|
781
|
-
# loop at two passes for a third-mutation window. This copy takes
|
|
782
|
-
# inflight.sh's single recount: a false refusal here costs one pass's wait,
|
|
783
|
-
# never a deletion, and a genuinely dropped entry is a standing state that
|
|
784
|
-
# survives every recount.
|
|
785
|
-
wtroot=
|
|
786
|
-
count_registry() {
|
|
787
|
-
registered=0
|
|
788
|
-
if [ -z "$wtroot" ]; then
|
|
789
|
-
wt_common=$(git rev-parse --path-format=absolute --git-common-dir 2>/dev/null) ||
|
|
790
|
-
{ reg_why="could not resolve the git common directory to read the worktree registry"; return 1; }
|
|
791
|
-
wtroot="$wt_common/worktrees"
|
|
792
|
-
fi
|
|
793
|
-
[ -e "$wtroot" ] || return 0
|
|
794
|
-
[ -d "$wtroot" ] && [ -r "$wtroot" ] && [ -x "$wtroot" ] ||
|
|
795
|
-
{ reg_why="worktree registry $wtroot could not be read"; return 1; }
|
|
796
|
-
for entry in "$wtroot"/*; do
|
|
797
|
-
[ -d "$entry" ] || continue
|
|
798
|
-
if contents=$(ls -A "$entry" 2>/dev/null) && [ -z "$contents" ]; then continue; fi
|
|
799
|
-
registered=$((registered + 1))
|
|
800
|
-
done
|
|
801
|
-
return 0
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
# Counts `$wt_list` as it stands; the caller decides whether to re-read it.
|
|
805
|
-
count_linked() {
|
|
806
|
-
listed=$(printf '%s\n' "$wt_list" | awk '/^worktree /{c++} END{print c+0}') ||
|
|
807
|
-
{ reg_why="could not count the worktrees git listed"; return 1; }
|
|
808
|
-
[ "$listed" -ge 1 ] ||
|
|
809
|
-
{ reg_why="git listed no worktrees at all — not even the main checkout"; return 1; }
|
|
810
|
-
linked=$((listed - 1))
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
# Reads the first `count_registry` the loop took ahead of the listing: an
|
|
814
|
-
# unreadable registry there has already set `reg_why`.
|
|
815
|
-
wt_registry_why() {
|
|
816
|
-
[ -z "$reg_why" ] || return 1
|
|
817
|
-
count_linked || return 1
|
|
818
|
-
if [ "$linked" -ne "$registered" ]; then
|
|
819
|
-
count_registry || return 1
|
|
820
|
-
wt_listing ||
|
|
821
|
-
{ reg_why="the recount could not re-read the worktree listing: $(printf '%s' "$wt_err" | tr '\n' ' ')"; return 1; }
|
|
822
|
-
count_linked || return 1
|
|
823
|
-
fi
|
|
824
|
-
if [ "$linked" -lt "$registered" ]; then
|
|
825
|
-
reg_why="git listed $linked linked worktrees for $registered registry entries in $wtroot — the listing dropped an entry, and a dropped entry names no branch"
|
|
826
|
-
return 1
|
|
827
|
-
elif [ "$linked" -gt "$registered" ]; then
|
|
828
|
-
reg_why="git listed $linked linked worktrees but only $registered registry entries were counted in $wtroot — the registry read missed entries git can see"
|
|
829
|
-
return 1
|
|
830
|
-
fi
|
|
651
|
+
# with no worktree is exactly as unclearable as the tampered one. Both run on
|
|
652
|
+
# the listing each branch's own lookup reads — re-read per branch, as the
|
|
653
|
+
# comment at the lookup below records — so a standing fault keeps every [gone]
|
|
654
|
+
# branch in the pass, and a transient one keeps only the branches whose
|
|
655
|
+
# listing it touched (a transient-fault fixture pins that granularity for the
|
|
656
|
+
# listing failure; this guard follows it rather than latching).
|
|
657
|
+
null_head_why() {
|
|
831
658
|
if ! nameless=$(printf '%s\n' "$wt_list" | awk '
|
|
832
659
|
function flush() { if (n > 1 && !br && h !~ /[^0]/ && hit == "") hit = w }
|
|
833
660
|
/^worktree /{ flush(); n++; w = substr($0, 10); h = ""; br = 0; next }
|
|
@@ -996,17 +823,10 @@ for b in $gone_branches; do
|
|
|
996
823
|
continue
|
|
997
824
|
fi
|
|
998
825
|
|
|
999
|
-
# The
|
|
1000
|
-
#
|
|
1001
|
-
#
|
|
1002
|
-
#
|
|
1003
|
-
reg_why=
|
|
1004
|
-
count_registry || :
|
|
1005
|
-
|
|
1006
|
-
# The path is the whole rest of the line, never awk's $2: `worktree list
|
|
1007
|
-
# --porcelain` prints it raw, so a checkout living under a directory with a
|
|
1008
|
-
# space in it — ordinary on macOS — was otherwise truncated at the first
|
|
1009
|
-
# one, and every check below then ran against a wrong, nonexistent path.
|
|
826
|
+
# The listing is read per branch, through worktree.sh's `wt_counts`, which
|
|
827
|
+
# counts the registry, reads the listing, checks the two agree, and leaves
|
|
828
|
+
# that listing in `$wt_list` for the lookup below — so the lookup scans the
|
|
829
|
+
# very listing the counts validated.
|
|
1010
830
|
#
|
|
1011
831
|
# A listing that cannot be read fails CLOSED, like every other could-not-check
|
|
1012
832
|
# in this file: `$wt` would be empty, every guard under `[ -n "$wt" ]` below
|
|
@@ -1019,36 +839,38 @@ for b in $gone_branches; do
|
|
|
1019
839
|
# own. Keeping it strands every [gone] branch in this pass on one repo-level
|
|
1020
840
|
# failure, since the listing is re-read per branch (header: every
|
|
1021
841
|
# precondition is recomputed); reap runs after every merge pass, so each waits
|
|
1022
|
-
# one pass with the cause named.
|
|
842
|
+
# one pass with the cause named. A listing that READ is not yet one that can
|
|
843
|
+
# be trusted — see the registry cross-check above — so a disagreeing registry
|
|
844
|
+
# keeps the branch the same way, under its own cause.
|
|
1023
845
|
#
|
|
1024
|
-
#
|
|
1025
|
-
#
|
|
1026
|
-
#
|
|
1027
|
-
#
|
|
1028
|
-
#
|
|
1029
|
-
#
|
|
1030
|
-
# own
|
|
1031
|
-
#
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
846
|
+
# `wt_find_branch` refuses rather than answering "no worktree" whenever its
|
|
847
|
+
# scan did not establish that: awk that could not finish (the multibyte
|
|
848
|
+
# trigger this file's header documents), or a holder git lists at a path
|
|
849
|
+
# inside its own registry. `keep`, not `die`: nothing has mutated $b yet, and
|
|
850
|
+
# dying here would also discard whatever earlier iterations of this loop
|
|
851
|
+
# already reaped — the same reason the branchless sweep below keeps rather
|
|
852
|
+
# than dies on its own listing read, and the same reason the listing failure
|
|
853
|
+
# above keeps.
|
|
854
|
+
if wt_counts; then :; else
|
|
855
|
+
case $? in
|
|
856
|
+
2)
|
|
857
|
+
keep "$b" "worktree lookup failed — cannot tell whether $b has a worktree; kept until a pass that can read the registry: $wt_why"
|
|
858
|
+
;;
|
|
859
|
+
*)
|
|
860
|
+
keep "$b" "worktree registry inconsistent — $wt_why; every [gone] branch is kept until a pass that reads a consistent registry"
|
|
861
|
+
;;
|
|
862
|
+
esac
|
|
1037
863
|
continue
|
|
1038
864
|
fi
|
|
1039
|
-
|
|
1040
|
-
# `wt_registry_why` above. After the `wt_listing` failure guard, before the
|
|
1041
|
-
# lookup, so the lookup scans the listing this check validated (a recount
|
|
1042
|
-
# re-reads it).
|
|
1043
|
-
if ! wt_registry_why; then
|
|
865
|
+
if ! null_head_why; then
|
|
1044
866
|
keep "$b" "worktree registry inconsistent — $reg_why; every [gone] branch is kept until a pass that reads a consistent registry"
|
|
1045
867
|
continue
|
|
1046
868
|
fi
|
|
1047
|
-
if !
|
|
1048
|
-
|
|
1049
|
-
keep "$b" "could not scan the worktree listing for $b — treating it as unresolved rather than guessing it has none"
|
|
869
|
+
if ! wt_find_branch "$b"; then
|
|
870
|
+
keep "$b" "$wt_why — treating it as unresolved rather than guessing it has none"
|
|
1050
871
|
continue
|
|
1051
872
|
fi
|
|
873
|
+
wt=$wt_path
|
|
1052
874
|
|
|
1053
875
|
# A newline in that path used to end the porcelain record before
|
|
1054
876
|
# `substr($0,10)` could read past it, so `$wt` was a prefix of the real path —
|
|
@@ -1094,7 +916,7 @@ for b in $gone_branches; do
|
|
|
1094
916
|
# directory. This `-f` test establishes only that the linkage EXISTS,
|
|
1095
917
|
# the same gate release-ticket.sh and worktree-audit.sh carry;
|
|
1096
918
|
# that it answers for `$wt` is established by the same-directory
|
|
1097
|
-
# `--show-toplevel` compare right after it (`
|
|
919
|
+
# `--show-toplevel` compare right after it (worktree.sh's `wt_linkage`).
|
|
1098
920
|
# The main checkout reaches here, and must be answered before the
|
|
1099
921
|
# linkage guard below sees it. `git worktree list --porcelain` emits a
|
|
1100
922
|
# `branch refs/heads/...` line for the main worktree too, so a `[gone]`
|
|
@@ -1123,8 +945,8 @@ for b in $gone_branches; do
|
|
|
1123
945
|
# Gated on `-f` rather than on "not kept above": an unsearchable `$wt`
|
|
1124
946
|
# fails `-f` too, and is left to the status probe below, which keeps it
|
|
1125
947
|
# with git's own "Permission denied" instead of a cause invented here.
|
|
1126
|
-
if [ -f "$wt/.git" ] && !
|
|
1127
|
-
keep "$b" "
|
|
948
|
+
if [ -f "$wt/.git" ] && ! wt_linkage "$wt"; then
|
|
949
|
+
keep "$b" "$wt_why"
|
|
1128
950
|
continue
|
|
1129
951
|
fi
|
|
1130
952
|
# `-uall`, never a bare `--porcelain`: the untracked mode is CONFIG, and
|
|
@@ -1290,9 +1112,9 @@ for b in $gone_branches; do
|
|
|
1290
1112
|
# removes the nested one's files too — taking any uncommitted work in it
|
|
1291
1113
|
# along, the same cwd deletion this guard exists for, one path further
|
|
1292
1114
|
# out — even though `$wt` itself never equals `$self_wt` in that shape.
|
|
1293
|
-
# `
|
|
1294
|
-
# the string.
|
|
1295
|
-
if
|
|
1115
|
+
# worktree.sh's `wt_holds_cwd` carries the match and why it is on the
|
|
1116
|
+
# directory, not only the string.
|
|
1117
|
+
if wt_holds_cwd "$wt" "$self_wt"; then
|
|
1296
1118
|
keep "$b" "worktree $wt holds the working directory this run was started in — removing it would delete the cwd every git call after it needs; rerun from outside it"
|
|
1297
1119
|
continue
|
|
1298
1120
|
fi
|
|
@@ -1670,8 +1492,8 @@ else
|
|
|
1670
1492
|
keep "" "worktree $wt has no .git linkage — git would answer for the enclosing repo, not this one"
|
|
1671
1493
|
continue
|
|
1672
1494
|
fi
|
|
1673
|
-
if [ -f "$wt/.git" ] && !
|
|
1674
|
-
keep "" "
|
|
1495
|
+
if [ -f "$wt/.git" ] && ! wt_linkage "$wt"; then
|
|
1496
|
+
keep "" "$wt_why"
|
|
1675
1497
|
continue
|
|
1676
1498
|
fi
|
|
1677
1499
|
# `-uall`: see the branch sweep's copy of this probe above for the
|
|
@@ -1732,7 +1554,7 @@ else
|
|
|
1732
1554
|
# Ancestor match, not exact equality — same reasoning as the branch
|
|
1733
1555
|
# sweep's copy of this guard: a worktree nested inside `$wt` is removed
|
|
1734
1556
|
# along with it even though `$wt` never equals `$self_wt` in that shape.
|
|
1735
|
-
if
|
|
1557
|
+
if wt_holds_cwd "$wt" "$self_wt"; then
|
|
1736
1558
|
keep "" "worktree $wt holds the working directory this run was started in — removing it would delete the cwd every git call after it needs; rerun from outside it"
|
|
1737
1559
|
continue
|
|
1738
1560
|
fi
|