sync: auto-sync from GURU-BEAST-ROG at 2026-05-25 13:17:49

Author: Mike Swanson
Machine: GURU-BEAST-ROG
Timestamp: 2026-05-25 13:17:49
This commit is contained in:
2026-05-25 13:17:52 -07:00
parent 6582f73f87
commit d74a726484
2 changed files with 27 additions and 1 deletions

View File

@@ -21,12 +21,19 @@ NC='\033[0m'
# content is never auto-deleted (use `git rm` for that, deliberately).
purge_garbled_paths() {
local rec st p removed=0
# POSIX ERE (not PCRE): `grep -P` refuses to run under non-UTF-8/unibyte locales on
# some platforms (Git Bash printed "grep: -P supports only unibyte and UTF-8 locales",
# silently disabling this guard). ERE has no such restriction; LC_ALL=C makes the match
# byte-wise. Same byte set as before: control chars / backslash / colon, plus the MSYS2
# Private-Use-Area substitutes (0xEE 0x80-0xBF = U+E0xx, 0xEF 0x80-0xA3 = U+F0xx) that
# stand in for : \ newline etc. in Windows path-as-filename cruft.
local garble_re=$'[\001-\037\\:]|\356[\200-\277]|\357[\200-\243]'
while IFS= read -r -d '' rec; do
st="${rec:0:2}"
p="${rec:3}"
[ -z "$p" ] && continue
[ "$st" = "??" ] || continue # untracked only
if printf '%s' "$p" | LC_ALL=C grep -qaP '[\x00-\x1f\\:]|\xee[\x80-\xbf]|\xef[\x80-\xa3]'; then
if printf '%s' "$p" | LC_ALL=C grep -qaE "$garble_re"; then
echo -e "${YELLOW}[WARNING]${NC} Removing garbled untracked path before staging: $(printf '%s' "$p" | cat -v)"
rm -f -- "$p" 2>/dev/null || true
removed=1