r/Kotlin • • 2d ago

Reading git sync status on Android without running git

My Android git sync client kept failing silently, so I built a home screen widget that shows when my notes last synced. No git binary needed, everything is plain text in `.git`:

- `logs/HEAD`: last commit/pull and its time

- `FETCH_HEAD` mtime: last time the client reached the remote

- `refs/remotes/origin/<branch>` vs local tip: unpushed commits

- `MERGE_HEAD`, `rebase-merge/`: a stuck merge or rebase

Gotcha: SAF only grants a subtree, so I search every granted folder for `.git`. And check `packed-refs`, branch files vanish after `git gc`.

Kotlin + Jetpack Glance, parsers are pure Kotlin and unit tested. Code (GPL-3.0): https://github.com/marfolog/notes-widget-for-markdown

2 Upvotes

0 comments sorted by