Git auto-commit and file history !486

merged merged by cmc on 2026-11-26 07:58 UTC · krz/orgstar:m5-git into main

Discussion

cmc 2026-11-26 07:57 UTC

Closes #95, closes #155.

#95 Git auto-commit (download version)

  • Settings ▸ Git: per sidebar folder that is a git repository, Off (default), Commit, or Commit, Pull and Push. Stored in user defaults gitAutoCommit as {root path: mode}. Absent in the App Store build (OrgPrograms isn't linked there).
  • Tracks the paths orgstar wrote (new DocumentSession.fileWritten, called from a FileSystem wrapper around replace in DocumentSession.saver, so buffer saves, Keep Mine, refile, archive, capture and agenda edits all report). Commits only those paths: git status on them, git add, git commit --only -- <paths>; other staged or unstaged changes are untouched. Message Update a.org, b.org, or Update N files with paths in the body.
  • When: 60 s after the last write in a folder (debounced per folder), and on quit (applicationShouldTerminate returns .terminateLater while files are pending).
  • Pull and push: git pull --no-rebase --ff-only before committing; on refusal nothing is merged, the commit is still made locally, push is skipped and the echo area says to resolve in a terminal. Push only after a successful pull and a commit.
  • No git at all while rebase-merge, rebase-apply, MERGE_HEAD, CHERRY_PICK_HEAD, REVERT_HEAD, BISECT_LOG or index.lock exists; files stay pending.
  • git is found like Emacs (ORGSTAR_GIT, Homebrew, /usr/local, nix, then Babel's PATH; /usr/bin/git only with developer tools installed). GIT_TERMINAL_PROMPT=0, GIT_ASKPASS/SSH_ASKPASS=/usr/bin/false with SSH_ASKPASS_REQUIRE=force, stdin /dev/null; 30 s local, 60 s network (15 s on quit). Auth failures are reported as such.
  • scripts/sync-strings.sh now also reads OrgPrograms' strings.

#155 File history

  • Mac: File ▸ History… (id app.recovery unchanged) replaces Recovery Versions…: recovery versions plus, in the download version, git log --follow commits for the file, merged by date, each diffed against the buffer, with Restore (DocumentSession.restore(text:), an undoable edit; buffer goes to recovery; no checkout).
  • iOS and the App Store build: recovery versions only. The iOS screen already had the diff against the buffer, so it is unchanged.

Tests

swift test (all green), both Xcode builds. New: GitAutoCommitTests (only orgstar's files committed with staged and unstaged work left alone, untracked new file, nothing to commit, no commit during a rebase, pull/commit/push fast-forward, ff-only refusal reported and push skipped, no credential prompt against a 401 server, debounce, flush on quit, off folder ignored, session hook) and FileHistoryTests (--follow across a rename, merge by date, restore from a commit). Real git in temporary repositories; skipped without git.

Manual: 01-files-and-folders (History, Committing to git), 03-keys, 13-configuration (Git pane), 15-alongside-emacs, install.

Checked on the Mac with ORGSTAR_SNAPSHOT in a copy with its own bundle ID: Settings ▸ Git and the History sheet with commits and a recovery snapshot.

Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form