Support Zig 0.16 alongside 0.15.2 via compat layer#5
Open
fielding wants to merge 3 commits into
Open
Conversation
Zig 0.16-dev reshaped the std I/O and process APIs (std.fs.File -> std.Io.File behind an Io instance, std.process.Init main convention, std.posix.getenv/execvpeZ removed). Isolate everything version-sensitive in src/compat.zig so the command modules stay on the shared std.Io.Writer interface, which is identical across both versions. - main: comptime-select a std.process.Init main (0.16) or zero-arg main (0.15); cli.run threads compat.ProcessInit through - stdout: writerStreaming on 0.16 - positional mode pwrites from offset 0 and overwrites earlier output when stdout is a redirected file - getenv/isatty/execvp: go through libc directly, one code path for both - git.zig: drop the realpath dance; libgit2 resolves "." and discovers upward itself Also correct the version claims (README said zig 0.14+, but the code has required 0.15 APIs since the writer rework; build.zig.zon now says 0.15.2), run the 143-test conformance suite in CI, and add informational zig-master CI jobs so 0.16 support stays honest. Verified: zig 0.16.0-dev.3128 build (Debug + ReleaseFast), zig build test, conformance 143/143, passthrough and non-repo error paths. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xan5eRiAXvcnAVvXHejdTz
First CI run of the conformance suite exposed that it only passed on hosts with init.defaultBranch=main: the merge-commit tests checkout main by name but the repo was created with bare git init. Use git init -b main. Verified locally with GIT_CONFIG_GLOBAL=/dev/null (143/143). Zig 0.16.0 is released (master is now 0.17-dev with further Build API breaks), so pin the matrix to 0.16.0 instead of chasing master, and drop the macos+0.15.2 job: the current runner images carry the macOS 26 SDK, which zig 0.15.2 cannot link against - main is equally unbuildable there. Verified against the real 0.16.0 release binary locally. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xan5eRiAXvcnAVvXHejdTz
The NIT_COLORS tests invoked script(1) with BSD/macOS positional-command syntax; util-linux script wants -c, so the suite died at the first TTY test on ubuntu runners. Add a run_tty helper that probes for -c support and %q-quotes args (color values contain semicolons that sh -c would otherwise interpret). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xan5eRiAXvcnAVvXHejdTz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The repo built on neither toolchain available on a current Mac: zig 0.15.2 fails at link against the macOS 26 SDK (same failure now on GitHub's macos-latest runners, so main is unbuildable in CI macOS too), and zig 0.16 changed the std I/O and process APIs the code relies on. This PR makes nit build and pass its full conformance suite on 0.16.0 while keeping 0.15.2 working where it still can (Linux).
What
src/compat.zig— new, ~55 lines: everything version-sensitive lives here. The command modules already target the sharedstd.Io.Writerinterface, which is identical across both versions, so they're untouched.std.process.Initmain (0.16) vs zero-arg main (0.15)writerStreamingon 0.16 — positional mode (thewriter()default) pwrites from offset 0 and silently overwrites earlier output when stdout is redirected to a filegetenv/isatty/execvp: go through libc directly; one code path for both versions since nit always links libcsrc/git.zig— dropped the realpath + dupeZ dance; libgit2 resolves"."and discovers upward itselfbuild.zig.zonminimum_zig_versionbumped to 0.15.2.git initwithout-b mainbroke the merge-commit tests on hosts withoutinit.defaultBranch=mainscript(1)syntax; util-linux needs-c(plus%qquoting, since color values contain semicolons)Verification
zig buildDebug + ReleaseFast,zig build test, conformance 143/143, also 143/143 withGIT_CONFIG_GLOBAL=/dev/null--stat, flag passthrough (diff --name-only), command passthrough (rev-parse), non-repo error path (exit 128)log -20; measured 90% and 93% on two real repos — the claim is conservative🤖 Generated with Claude Code
https://claude.ai/code/session_01Xan5eRiAXvcnAVvXHejdTz