Fix stat mtime detection on Linux (sync-age display broken)#49
Merged
ykdojo merged 1 commit intoJul 23, 2026
Merged
Conversation
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.
ykdojo
approved these changes
Jul 23, 2026
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.
On GNU/Linux,
stat -fis a valid flag (it prints filesystem status), so it succeeds instead of erroring — the|| stat -c %Yfallback never fires.$fetch_timethen captures multi-line filesystem output,$((now - fetch_time))throwssyntax error in expression, and the git sync-age (synced Nm ago) never renders.Fix: try the GNU form (
-c %Y) first, fall back to BSD/macOS (-f %m):Correct on both platforms: Linux hits
-cfirst; macOS errors on-c(BSD stat has no-c) and falls through to-f %m. One-line change, no behavior change on macOS.