From a1e796092dadfc264086c2a2d66962449ab9fca0 Mon Sep 17 00:00:00 2001 From: "TJ@axp-dev" Date: Wed, 22 Jul 2026 20:16:00 +0000 Subject: [PATCH] fix: correct stat mtime detection on Linux (GNU coreutils) On GNU/Linux, `stat -f` is a valid flag (filesystem status) that succeeds rather than erroring, so the `|| stat -c %Y` fallback never fired and $fetch_time captured multi-line filesystem output. That broke the $((now - fetch_time)) arithmetic and the sync-age display. Try the GNU form (`-c %Y`) first, fall back to the BSD/macOS form (`-f %m`). Correct on both platforms: Linux hits -c first; macOS errors on -c and falls through to -f. --- scripts/context-bar.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/context-bar.sh b/scripts/context-bar.sh index 6b56337..a1929e6 100755 --- a/scripts/context-bar.sh +++ b/scripts/context-bar.sh @@ -45,7 +45,7 @@ if [[ -n "$cwd" && -d "$cwd" ]]; then fetch_head="$cwd/.git/FETCH_HEAD" fetch_ago="" if [[ -f "$fetch_head" ]]; then - fetch_time=$(stat -f %m "$fetch_head" 2>/dev/null || stat -c %Y "$fetch_head" 2>/dev/null) + fetch_time=$(stat -c %Y "$fetch_head" 2>/dev/null || stat -f %m "$fetch_head" 2>/dev/null) if [[ -n "$fetch_time" ]]; then now=$(date +%s) diff=$((now - fetch_time))