Skip to content

feat: native git module and themed gitmux background - #13

Merged
jals1212 merged 8 commits into
mainfrom
feat/git-module
Jul 2, 2026
Merged

jals1212 merged 8 commits into
mainfrom
feat/git-module

Conversation

@jals1212

@jals1212 jals1212 commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a native git status-line module and keeps gitmux fully supported with one readability fix:

  • New git module (modules/git.conf + utils/git_status.sh): minimal output — main ✓ clean, main ! 1C 1S 2M 1? dirty (conflicts, staged, modified, deleted, untracked; zero groups omitted; short SHA when detached). No inline colour codes: the text block is styled natively, so every themux prop (variant, accent, shape, notch, padding, cascade) applies. A dirty repo escalates the accent through the existing _active_when machinery (teal → peach by default). Rendered only inside a git work tree; no external dependency.
  • gitmux: unchanged except its text-block background now defaults to the theme's crust, so gitmux's stock colours (designed for dark bars) read correctly on themed surfaces. Overridable via @themux_gitmux_text_bg.
  • Raw bg overrides now respect naked: a per-slot bg override no longer paints an opaque block on a channel whose resolved variant is naked (per-channel gating in module_render.sh).

Changes

File Change
modules/git.conf New module: icon/accents, rev-parse when gate, _active_when dirty escalation, quoted script invocation
utils/git_status.sh One-pass --porcelain -b XY-column parser (conflicts/staged/modified/deleted/untracked), --dirty mode, detached fallback
modules/gitmux.conf Text bg defaults to #{E:@thm_crust}
utils/module_render.sh Per-slot bg overrides gated per channel on naked
themux.conf Source the new module
tests/git_module.sh (+expected) Throwaway-repo coverage: clean/dirty/detached/unborn, conflict (real UU + fabricated AA/DD), untracked dirty parity, cleanup trap
docs/reference/*.md Git module docs, git-vs-gitmux guidance, corrected stale @themux_module_<name>_bg_color option name

Test plan

  • Full suite green: tests/run_tests.sh — 16/16 (15 existing + new git_module)
  • shellcheck -a clean on all scripts
  • Script behavior verified against throwaway repos: clean, staged/modified/deleted/untracked counts, merge conflicts, detached HEAD, unborn branch, paths with spaces

jals1212 added 8 commits July 2, 2026 09:04
Branch plus a minimal clean/dirty summary printed as plain text by
utils/git_status.sh, so the block is styled natively by variant/accent
and a dirty work tree warms the accent through the shared active
machinery (@themux_git_active_when backed by a cheap tracked-only
probe). Renders only inside a git work tree, like gitmux.
gitmux's default palette targets a black bar; defaulting the text block
to @thm_crust keeps those colours readable on any theme surface.
Asserts the when gate, dirty escalation and script invocation wiring,
the gitmux text background default, and runs git_status.sh against a
throwaway repo through clean, staged, modified/untracked, --dirty probe,
symbol override and non-repo states.
Adds the Git module entry (options, dirty escalation, when to prefer it
over gitmux), notes gitmux's new text background default, registers git
in the built-in module list, and fixes the stale per-module background
override to the real @themux_<name>_text_bg option.
A raw per-channel _text_bg/_icon_bg override was applied unconditionally to
both the resting and active channel, so gitmux's crust text background (the
default since the previous commit) painted an opaque block even under the
naked variant, which promises a transparent background. Gate each bg
override by that channel's own resolved variant instead.
…d path

The staged count rendered as "<n>A" while counting every X in [MTADRC],
which reads as "added" but really means "staged" — relabel it "S". An
unmerged XY pair (UU, AU, UA, DU, UD, DD, AA) was counted straight into the
staged/modified/deleted groups instead of its own conflicts group, so a
conflicted file rendered as an ordinary change; detect it first and count
it as "<n>C" ahead of the rest. --dirty used status --porcelain -uno
(tracked changes only) while the text mode counts untracked files too, so
an untracked-only work tree showed "! 1?" in the text but kept the accent
resting; drop -uno so both passes agree. Quote the script path in both
#() invocations in git.conf so an install path containing spaces doesn't
break the command.
Add a real UU conflict repo (two branches editing the same line, then a
failed merge) asserting "<branch> ! 1C", then layer a fabricated add/add
and delete/delete pair onto the same unresolved merge to assert AA/DD
count as conflicts instead of leaking into the staged/deleted groups.
Cover the untracked-only --dirty/text parity fix and the quoted script
path invocations, and update the staged-label expectation to "S". Trap
the temp repos right after mktemp so the harness ERR-trap path can't
leak them.
The conflict fixtures built a UU via a real `git merge` and layered a
fabricated AA/DD on top of it. On CI (no git identity configured, unlike
this machine's global gitconfig) the un-`-c`'d merge aborted immediately
with "unable to auto-detect email address" before ever attempting the
merge, an error silently swallowed by `|| true`; the repo was left clean
("main ✓" instead of "main ! 1C"), and the AA+DD fabricated on top of that
unchanged state only produced 2 conflicts instead of 3. Both mismatches
were the same root cause, not two separate bugs.

Fabricate all three conflict types (UU, AA, DD) directly through index
stages instead — the same stage combination git itself uses to derive the
XY code (1+2+3 = UU, 2+3 with no 1 = AA, 1 alone = DD) — so the fixture no
longer depends on a real merge's identity requirement, diff outcome or
version-specific merge machinery. Each fabrication is verified against a
fresh `git status --porcelain` right away via a require_conflict() guard,
so a stanza that fails to register is an immediate, clearly labelled
failure instead of a silently wrong count downstream.
@jals1212
jals1212 merged commit 775f630 into main Jul 2, 2026
2 checks passed
@jals1212
jals1212 deleted the feat/git-module branch July 2, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant