Commit f224a76
fix(dashboard,wslg): clean grep -c counts + WSLg env propagation
Two visible glitches in the dashboard's "Working tree" panel and a
silent flatpak-GUI-launch failure under WSLg, both rooted in
shell-quirk / namespace-quirk that's specific to podman-machine WSL
distros' nested systemd setup.
1. dashboard "Working tree" rendered:
staged 0
0
modified 0
0
untracked 497
Two-line counts where there should be one.
Root cause: `grep -c <pattern>` exits 1 when match count is 0
(POSIX). The previous code did `grep -cE ... || echo 0` -- when
no matches existed, BOTH `grep -c 0\n` AND `echo 0\n` ran, and
the captured value was "0\n0" (one trailing newline trimmed by
$(...)). printf rendered it across two rows.
Fix: pipe the porcelain output once into a local var, then run
each grep -c against that var with `2>/dev/null; true` (lets the
command substitution always succeed) and a trailing
`${var%%[!0-9]*}` to strip any non-digit suffix. The resulting
var is always exactly one integer.
Also fix `ahead`/`behind` rendering as "?": the previous code
tried `git rev-list --count '@{upstream}..HEAD'` which errors
when no upstream tracking branch is set on the local branch.
Now probes `refs/remotes/origin/<branch>` first; if present,
uses the explicit `origin/<branch>..HEAD` form. Otherwise shows
"?" without the rev-list stderr leak.
2. /etc/profile.d/mios-wslg.sh: new file. Exports DISPLAY,
WAYLAND_DISPLAY, XDG_RUNTIME_DIR, PULSE_SERVER, WSL_INTEROP for
shells that land in the NESTED systemd namespace of a
podman-machine WSL distro. The outer namespace mounts /mnt/wslg/
(with the wayland socket, PulseServer pipe, etc.); the inner
ns (where the operator's interactive shell lives) does NOT
inherit the env that points at those sockets, so flatpak GUI
apps (Ptyxis, Nautilus, Epiphany, etc.) error with
"Gdk-CRITICAL ... 'GDK_IS_DISPLAY (self)' failed" or
"cannot open display:" the moment they launch.
Detection is by `[ -d /mnt/wslg ]` -- present only on WSLg-
capable distros, so the file is inert on bare-metal /
Hyper-V / QEMU MiOS hosts.
Verified live on podman-MiOS-DEV:
DISPLAY=:0 WAYLAND_DISPLAY=wayland-0
XDG_RUNTIME_DIR=/mnt/wslg/runtime-dir
/mnt/wslg/{distro,doc,PulseAudioRDPSink,PulseAudioRDPSource}
branch 'main' set up to track 'origin/main'.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent 907cec9 commit f224a76
2 files changed
Lines changed: 61 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
179 | | - | |
| 179 | + | |
180 | 180 | | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
186 | 206 | | |
187 | 207 | | |
188 | 208 | | |
| |||
0 commit comments