No .gitattributes: every Windows clone gets CRLF in scripts/gate.sh and the gate dies with bash\r (exit 127)
#19
Labels
No Label
blocked
bounced
in-progress
in-review
manual-only
needs-guidance
netplay
p1
p2
p3
rust
No Milestone
No project
No Assignees
1 Participants
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: pbwraith/gopher64-netplay#19
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
scripts/gate.shbreaks in any Windows clone, because this repo has no.gitattributesSmall, cheap, and worth fixing now that
scripts/gate.shis the repo's keystone - eight open PRs are gated by it, so anything that makes it fail confusingly costs more here than it would elsewhere.The measurement
No
.gitattributesonmain, and none onissue-16either. The repo ships three shell scripts:The committed blobs are clean -
git cat-file -p origin/issue-16:scripts/gate.sh | tr -cd '\r' | wc -cis 0. The problem is not what is stored, it is what gets written on checkout.Why it bites
Git for Windows defaults to
core.autocrlf=true. With no.gitattributesto override it, cloning this repo on Windows writes CRLF into every.shworking copy, and the script then dies at exec:This already happened during review of
!17: the first gate run failed exactly this way, and it took a round of investigation to establish it was a clone artifact rather than a defect in the PR.env: 'bash\r'does not name line endings, and the natural reading is "the script is broken" - which is the wrong conclusion about a script whose blob is byte-clean.The workaround is
git config core.autocrlf falseplus a fresh checkout, but that is per-clone tribal knowledge. The repo should assert its own requirement.What to do
Add
.gitattributesat the repo root:Consider
* text=autoalongside it if you want the general rule, but the.shline is the one that fixes the observed failure.The part that is easy to get wrong
.gitattributesalone does not fix an already-checked-out working copy. Git does not rewrite a file on branch switch when its blob is unchanged, so a clone that already has CRLF inscripts/gate.shwill still have CRLF after merging this change - on a branch whose blobs are perfectly clean. Existing clones need a forced re-checkout:If any committed blob did contain CR (none do here, so this should be a no-op), fixing it needs
git add --renormalize .as a separate commit - the attributes file does not retroactively clean stored objects.Acceptance criteria
.gitattributesexists onmainand contains*.sh text eol=lf.core.autocrlf=true(the default - set it explicitly for the test rather than relying on the box's config),tr -cd '\r' < scripts/gate.sh | wc -creturns 0. State the command and the number.head -c 24 scripts/gate.sh | od -cshows a clean#!/usr/bin/env bashshebang with no\r..shfiles are covered, not justscripts/gate.sh.Measurement warning
Do not verify this with
grep -c $'\r'. It is broken in this environment's Git Bash and returns the line count, not the CR count - it has produced false findings on three separate occasions here, and the tell is that the number always equalswc -l. Usetr -cd '\r' < file | wc -c, and treat actually running./scripts/gate.sh --help(or any invocation that reaches the interpreter) as the deciding test.Out of scope
scripts/gate.sh's contents or to the build configuration. This is line endings only.[worker] lane3 implemented — PR #21 (branch
issue-19, basemain).Commit:
cfa4694"Add .gitattributes: *.sh text eol=lf for Windows clones" (rebased onto current main8a46ac5; diff = new.gitattributesonly,git diff --checkclean).Verification (fresh clones with
core.autocrlf=trueset explicitly):.gitattributes):tr -cd '\r' < scripts/gate.sh | wc -c= 81; generate.sh = 6, output.sh = 5; shebang hadbash\rand./scripts/gate.shfailed with/usr/bin/env: 'bash\r': No such file or directory, EXIT=127 (reproduced).tr -cd '\r' < scripts/gate.sh | wc -c= 0 (and 0 for the other two .sh files);head -c 24 scripts/gate.sh | od -cshows a clean#!/usr/bin/env bash\nshebang with no\r;bash -nparse check passes for all three scripts.Full cargo gate not run: blocked by the known disk-space issue (gitea-worker-ops#24); per the issue this change is verifiable by inspection and a fresh clone.